max / makeover-layout
| 1 | //! The renderer-agnostic half of the make-family design system. |
| 2 | //! |
| 3 | //! <!-- wiki: makeover-layout --> |
| 4 | //! |
| 5 | //! `makeover` answers *what colour*, and varies by theme. `makeover-geometry` |
| 6 | //! answers *how much space*, and varies by density and surface. This crate |
| 7 | //! answers *what the thing is*, and varies by nothing. |
| 8 | //! |
| 9 | //! # The deferral rule |
| 10 | //! |
| 11 | //! A description names intents and relationships, never values. Say |
| 12 | //! [`Fill::Raised`], never `#D9DDF4`. Say `Gap::Peer`, never `6px`. What is |
| 13 | //! left once colour and spacing are deferred is **composition**: which edges |
| 14 | //! are lit, what inverts on press, what nests in what. |
| 15 | //! |
| 16 | //! The constraint that shapes all of it: a renderer that can only paint |
| 17 | //! rectangles has to be able to express the result. egui has no |
| 18 | //! `box-shadow: inset` and one stroke per widget with no per-side control; a |
| 19 | //! terminal has box-drawing characters and one cell of resolution, and cannot |
| 20 | //! draw a two-tone lit edge at all. A description that assumes per-side edges |
| 21 | //! is a CSS description wearing a neutral name. So this crate names the |
| 22 | //! *intent* — this region is a well — and each renderer chooses an expression |
| 23 | //! it can actually produce, including dropping half of one. |
| 24 | //! |
| 25 | //! # Scope |
| 26 | //! |
| 27 | //! Depth came first: the bevel and the surfaces it shapes. That much was |
| 28 | //! settled the hard way — the vocabulary here was read off audiofiles' |
| 29 | //! `ui::theme` and `ui::widgets`, which are the only implementation written |
| 30 | //! by a consumer with no CSS, then checked against both webview apps. All |
| 31 | //! three agreed once Balanced Breakfast's fills were corrected. |
| 32 | //! |
| 33 | //! 0.2.0 adds the rest of the description, each member drawn the same way, |
| 34 | //! from what the three apps already hand-write rather than from a taxonomy: |
| 35 | //! |
| 36 | //! - Components. [`Token`] (badge against chip), [`Notice`] (toast against |
| 37 | //! banner), [`RowPart`], [`Heading`], [`Selector`], [`Readiness`], and |
| 38 | //! [`Tone`], which is the one intent family they share. |
| 39 | //! - Schemas. [`Field`] for forms and [`Column`] for lists and tables. |
| 40 | //! - Structure. [`Region`] for the parts of a screen, [`Arrangement`] for how |
| 41 | //! a screen is put together. |
| 42 | //! |
| 43 | //! **Validation** was absent on purpose here, on the grounds that neither app |
| 44 | //! had a shared story. That reasoning is retired — see 0.11.0 below, which is |
| 45 | //! where the constraints arrived and why the argument did not survive contact |
| 46 | //! with what the apps were measured to do. |
| 47 | //! |
| 48 | //! 0.3.0 closes a gap the first real adoption found, which is what adopting |
| 49 | //! against goingson first was for. [`Selector`] described only the *chosen* |
| 50 | //! option, so an unchosen one fell through to [`Depth::Flat`] and no renderer |
| 51 | //! drew it; goingson's tab strip recesses its unchosen tabs by hand and could |
| 52 | //! not delete the line, because being recessed is *why* the chosen tab reads as |
| 53 | //! coming forward. So [`Selector::unchosen`] joins `chosen`, and saying it |
| 54 | //! needed [`Fill::Sunken`] and [`Depth::Sunken`]: a surface set back by colour |
| 55 | //! with no edge, which is neither a well nor level-with. |
| 56 | //! |
| 57 | //! 0.7.0 adds [`State`], the interaction axis, closing the gap that adopting |
| 58 | //! against three apps rather than one made visible. The description named |
| 59 | //! rest and, through [`Depth::pressed`], pressed. It named neither focus nor |
| 60 | //! disabled, so `makeover-webview` emitted a hover rule and stopped, and each |
| 61 | //! consumer completed the primitive from outside by out-specifying a rule it |
| 62 | //! did not own: 19 such rules in goingson, 21 in the MNW server, a further set |
| 63 | //! in Balanced Breakfast, and three focus rings that do not match. The axis is |
| 64 | //! deliberately two members wide, because hover and pressed belong where they |
| 65 | //! already are. [`State`]'s own docs carry that argument. |
| 66 | //! |
| 67 | //! 0.8.0 finishes [`Field`], which described a field well enough to label it and |
| 68 | //! not well enough to draw it. Writing `makeover-webview`'s form emitter found |
| 69 | //! three things missing and the renderer supplied all three from outside: the |
| 70 | //! current value, a select's options, and the placeholder. Two of those move |
| 71 | //! here and one does not. |
| 72 | //! |
| 73 | //! - [`Field::placeholder`] is user-facing text sitting beside `label` and |
| 74 | //! `hint`. There was never a reading on which it was renderer state; it was |
| 75 | //! outside only because adding a field to a published struct is breaking. |
| 76 | //! - [`Field::options`] moves because every renderer needs them and each was |
| 77 | //! going to invent its own shape. [`Choice`] is the shape `makeover-webview` |
| 78 | //! already arrived at, taken as-is rather than redesigned. |
| 79 | //! - The current value stays renderer-side and is not coming here. It is the |
| 80 | //! one of the three that is genuinely state: a webview reads it out of the |
| 81 | //! DOM, an immediate-mode renderer holds a `&mut` to the app's own field, and |
| 82 | //! a description that carried it would be a form model. |
| 83 | //! |
| 84 | //! 0.9.0 opens [`RowPart`], which was the last closed enum in the vocabulary, |
| 85 | //! and adds [`RowPart::Tokens`]. Both halves come from the same finding, made |
| 86 | //! by the first two real screens described through the router rather than by |
| 87 | //! reading a stylesheet. |
| 88 | //! |
| 89 | //! A goingson project card carries two trailing badges, a type and a toned |
| 90 | //! status; a contact card carries a primary email *and* a strip of tags. `Meta` |
| 91 | //! is one slot and one string, so both ports joined their facts with a |
| 92 | //! separator and lost what the second one was: a status reads as text where it |
| 93 | //! used to read as colour. [`Token`] already says exactly the right thing — a |
| 94 | //! small labelled thing with a kind, a tone and an optional action — and could |
| 95 | //! only ever be a node in its own right, never inside a row. |
| 96 | //! |
| 97 | //! So the missing thing was permission rather than a concept. `Tokens` is that |
| 98 | //! permission, and `#[non_exhaustive]` arrives with it so the next member is not |
| 99 | //! a lockstep event across three renderers. The pairing is the point: this |
| 100 | //! enum's own consumer in `makeover-webview` carried a comment predicting it |
| 101 | //! would stop compiling one day, which is a lockstep break written down and |
| 102 | //! waited for rather than prevented. |
| 103 | //! |
| 104 | //! Balanced Breakfast was checked before the member was added, because one |
| 105 | //! consumer wanting something is not evidence. It packs a count and two icon |
| 106 | //! buttons into the same single `Meta` slot while leaving `Actions` empty, so |
| 107 | //! the slot was already straining under a second consumer for a different |
| 108 | //! reason. |
| 109 | //! |
| 110 | //! 0.10.0 adds [`Meter`], a proportion carried as a pair rather than as a |
| 111 | //! percentage. Its own docs carry the argument; the short form is that the |
| 112 | //! percentage shape had already been tried in goingson and had already needed a |
| 113 | //! companion flag to recover what rounding and clamping threw away. |
| 114 | //! |
| 115 | //! 0.11.0 is four members from the quasi proving ground, batched into one |
| 116 | //! release because pre-1.0 a minor is breaking and a cascade is nine repos. |
| 117 | //! Three findings that arrived with them turned out not to belong here at all: |
| 118 | //! this crate has no notion of an action, a route or a destination, so anything |
| 119 | //! asking what a control *calls* was never the vocabulary's to say. |
| 120 | //! |
| 121 | //! - [`Figure`], a value with a caption. goingson had five of them across five |
| 122 | //! screens with five class vocabularies for the one shape, which is the |
| 123 | //! divergence this crate exists to end, sitting in plain sight and counted for |
| 124 | //! the first time. |
| 125 | //! - [`RowPart::Proportion`], so a [`Meter`] can sit in a row. `Meter` reached |
| 126 | //! two of its seven sites at 0.10.0 and the other five are row-shaped. Exactly |
| 127 | //! [`RowPart::Tokens`]'s problem with a different payload, and it takes |
| 128 | //! `Tokens`' answer: the part carries the description of a bar, not a node. |
| 129 | //! - [`Field::max_length`], [`Field::min`] and [`Field::max`], joining |
| 130 | //! [`Field::required`], which had been sitting here as the sole constraint |
| 131 | //! while the header above claimed there were none. The set stops before |
| 132 | //! `pattern`, which fails the renderer test and is one site in one app. |
| 133 | //! - [`FieldKind::File`]. Every host has an honest answer — a native picker, an |
| 134 | //! `<input type="file">`, a path prompt, an argument — and it carries no |
| 135 | //! accepted-types list because `accept` appears at zero sites in either app. |
| 136 | //! |
| 137 | //! The evidence rule changed under these, and it is worth recording because four |
| 138 | //! earlier decisions were made under the old one. The two-app test said a shape |
| 139 | //! earns a word once a second app wants it. It is backwards: a rule that |
| 140 | //! withholds a word until a second app has duplicated the code guarantees the |
| 141 | //! duplication, and app three writes it a third time. The bar is now generic |
| 142 | //! against bespoke — is this furniture any app would have, or is it this app's |
| 143 | //! own? Bespoke keeps [`Region::Bespoke`], which already carries a completion |
| 144 | //! heatmap and is the right answer for a calendar nobody will build twice. |
| 145 | //! |
| 146 | //! 0.12.0 is two more from the same proving ground, and the same sorting |
| 147 | //! happened first: six findings came out of a measurement of goingson's whole |
| 148 | //! frontend, and four of them turned out to be asking what a control *calls*, |
| 149 | //! which this crate cannot say. The two that were really here: |
| 150 | //! |
| 151 | //! - [`Readiness`] grows from two states to four. It named `Ready` and |
| 152 | //! `Pending` and stopped, so a screen whose list came back empty had nothing |
| 153 | //! to say about it; goingson draws an empty state at 27 sites and Balanced |
| 154 | //! Breakfast at 9. `Empty` and `Failed` are the same axis rather than a new |
| 155 | //! member beside it, because a region shows one of the four and never two. |
| 156 | //! `#[non_exhaustive]` arrives with them, the pairing [`RowPart`] made at |
| 157 | //! 0.9.0 and for the same reason. |
| 158 | //! - [`Column::sortable`], [`Column::sorted`] and [`Sort`]. The one finding in |
| 159 | //! the set that completes a member rather than adding one: `Column` shipped |
| 160 | //! with a width and a priority and could not say that a table is ordered by a |
| 161 | //! column, so a described table could draw no caret and offer no reordering. |
| 162 | //! |
| 163 | //! 0.14.0 is two additive members on two `#[non_exhaustive]` enums, released |
| 164 | //! together because publishing twice for that is waste and the cascade below |
| 165 | //! this crate is nine repos. |
| 166 | //! |
| 167 | //! - [`Depth::Overlay`]. The enum could say raised, well, sunken and flat, and |
| 168 | //! could not say that a surface sits *over* the page. Every renderer already |
| 169 | //! had the surface — `makeover-tui`'s `Palette::overlay`, |
| 170 | //! `makeover-immediate`'s `Palette::elevation`, `makeover-webview`'s |
| 171 | //! `--elevation-overlay` — and none of them could be reached from a |
| 172 | //! description. buckets_of_money has 16 modals waiting on it. |
| 173 | //! - [`CellPart`], which is [`RowPart`] for tables. A row's parts have carried |
| 174 | //! their own content intent since 0.2.0, so `.row-actions` inherits rather |
| 175 | //! than taking a text colour; a table cell had no such vocabulary and |
| 176 | //! `makeover-webview` emitted one undifferentiated `.cell`, so a button in a |
| 177 | //! cell was painted as text. The four members are the four things quasi's |
| 178 | //! `Cell` was measured to hold, and the count is in that crate's history |
| 179 | //! rather than assumed here. |
| 180 | //! |
| 181 | //! 0.15.0 adds [`FieldKind::Date`] and [`FieldKind::DateTime`], on the argument |
| 182 | //! [`FieldKind::Email`] was admitted on: a webview emits a different `type=`, |
| 183 | //! which is a native picker, the platform's validation and a different keyboard |
| 184 | //! on a touch device. Described as text with a "YYYY-MM-DD" hint, all three are |
| 185 | //! lost. |
| 186 | //! |
| 187 | //! Two members and not one or five, from a count rather than from symmetry: 13 |
| 188 | //! sites of `date` and 13 of `datetime-local` across the MNW server and |
| 189 | //! goingson, and zero of `time`, `month` or `week`. The wire format each takes |
| 190 | //! is named here as [`DATE_FORMAT`] and [`DATETIME_FORMAT`], because a host |
| 191 | //! left to pick its own would disagree with a server silently, and |
| 192 | //! [`FieldKind::temporal`] is the pair asked about once rather than at each |
| 193 | //! renderer. `FieldKind`'s own comment claiming `radio` was the last HTML input |
| 194 | //! type missing was already false when 0.8.1 wrote it; these are what it was |
| 195 | //! missing. |
| 196 | //! |
| 197 | //! What each of the 0.12.0 findings deliberately leaves out is the address — what pressing a |
| 198 | //! header calls, and where an empty state's "Add your first project" button |
| 199 | //! goes. That is the boundary this crate is defined by, and four findings moved |
| 200 | //! across it rather than being answered here. |
| 201 | //! |
| 202 | //! 0.19.0 narrows [`State`] to [`State::Disabled`] alone. `State::Focus` is |
| 203 | //! gone: a description never states what has focus, because what focus *is* |
| 204 | //! differs per host and every renderer had already decided for itself — the |
| 205 | //! webview draws it from `:focus-visible`, egui refused the variant outright, |
| 206 | //! and quasi-tui honoured it once at startup and overrode it thereafter. |
| 207 | //! |
| 208 | //! 0.20.0 adds [`Region::Widget`], the third tier, and `#[non_exhaustive]` to |
| 209 | //! [`Region`] with it. Every vocabulary finding until now had two answers |
| 210 | //! available — grow the primitive set, or [`Region::Bespoke`] — and a whole |
| 211 | //! class of thing is wrong for both. A carousel is not a primitive, because a |
| 212 | //! terminal has none and that is the test `Node::Html` failed. It is not |
| 213 | //! bespoke either, because bespoke is what one app owns and every part of a |
| 214 | //! carousel is furniture plus members this crate already has. |
| 215 | //! |
| 216 | //! The cost of the binary was that refusing a primitive was expensive: the app |
| 217 | //! hand-rolls the thing forever, so the pressure always ran toward growing the |
| 218 | //! primitive set with one host's idioms. A named assembly changes what "no" |
| 219 | //! costs without changing what the vocabulary can say. |
| 220 | //! |
| 221 | //! MNW's carousel is the first consumer and was the finding that started it: one |
| 222 | //! partial, three pages, an ordered set of frames with a position, prev/next and |
| 223 | //! a dot strip, all of it sayable already and none of it nameable. See wiki |
| 224 | //! `widget-tier` for the ownership model, which is why this member carries a |
| 225 | //! name a renderer may decline to know. |
| 226 | //! |
| 227 | //! 0.21.0 adds [`Image`] and [`Fit`], found by trying to describe MNW's |
| 228 | //! carousel under 0.20.0's widget tier and getting one step in. Nothing named a |
| 229 | //! picture. The vocabulary could say a number with a caption, a badge, a meter |
| 230 | //! and a table, and could not say the thing three of MNW's public pages are |
| 231 | //! mostly made of. |
| 232 | //! |
| 233 | //! It reads as an oversight and is a measurement: 24 `<img>` sites across 22 |
| 234 | //! MNW templates, against one in goingson and none in Balanced Breakfast or |
| 235 | //! audiofiles. A picture is furniture a *content platform* has, and MNW is the |
| 236 | //! only one in the tree, so the evidence never arrived from the two-app |
| 237 | //! direction the earlier rule looked in. Under the generic-against-bespoke bar |
| 238 | //! it is not close: a picture is not one app's own. |
| 239 | //! |
| 240 | //! A primitive rather than a widget, which is worth stating now that the tier |
| 241 | //! makes it a real question. A widget is an assembly of things already sayable |
| 242 | //! and a picture is a leaf, assembled from nothing. It also passes the test |
| 243 | //! `Node::Html` failed — every host has an honest answer, including a terminal, |
| 244 | //! which has a graphics protocol or has [`Image::alt`]. |
| 245 | //! |
| 246 | //! [`Image`] carries no source, the split [`Act`] already makes: an address is |
| 247 | //! not this crate's to hold. See its own docs, which is where the argument is. |
| 248 | //! |
| 249 | //! 0.22.0 finishes [`Image`], which 0.21.0 shipped unable to say how much room |
| 250 | //! a picture needs. Without that a renderer cannot reserve space, so a picture |
| 251 | //! occupies nothing until its bytes arrive and then takes its full height at |
| 252 | //! once. Measured on MNW's landing page: a 478px jump per frame and a |
| 253 | //! cumulative layout shift of 0.087 for the page. |
| 254 | //! |
| 255 | //! - [`Image::intrinsic`], the picture's own dimensions, carried as [`Extent`]. |
| 256 | //! A fact about the asset rather than a display size, which is what keeps it |
| 257 | //! on this side of the deferral rule: 5120x3412 is what the file *is*, and no |
| 258 | //! renderer can learn it without fetching the bytes. |
| 259 | //! - [`Loading`], and the default flips to [`Loading::Eager`]. 0.21.0 emitted |
| 260 | //! the webview's `loading="lazy"` for every picture, which read one |
| 261 | //! consumer's habit as a rule. Deferring a picture that is on screen at first |
| 262 | //! paint saves nothing and makes its shift land later. The carousel is the |
| 263 | //! case that proves this cannot be one renderer-wide setting: its first frame |
| 264 | //! is on screen and its others are not, in one widget, at one moment. |
| 265 | //! |
| 266 | //! 0.23.0 adds [`Showing`], which is three open findings collapsing into one |
| 267 | //! member. A tab group could not say which tab was open, a carousel could not |
| 268 | //! say which frame was up, and a disclosure could not say whether its child was |
| 269 | //! showing. All three are the same missing sentence, and while it was missing a |
| 270 | //! renderer had two moves: match on a widget name, or draw every child. |
| 271 | //! |
| 272 | //! So the widget tier was taking the blame for a gap one level below it. With |
| 273 | //! this a renderer derives its chrome from the description — labels get a strip, |
| 274 | //! no labels get previous/position/next — once, for every widget there will ever |
| 275 | //! be, and [`Region::Widget`]'s name goes back to being app vocabulary a |
| 276 | //! renderer may decline to know. |
| 277 | //! |
| 278 | //! Only the kind lives here. Which child is up, and what each child is called, |
| 279 | //! sit with whatever holds the regions, the same split [`Selector`] already made |
| 280 | //! against `Node::Select`. |
| 281 | //! |
| 282 | //! 0.27.0 adds [`Region::Group`], which closes a gap this crate had carried |
| 283 | //! since 0.2.0 without noticing: [`Heading::Section`] is documented as naming a |
| 284 | //! block within the screen, and there was no block. A section heading is a leaf |
| 285 | //! beside the things it names, so the description could say a section had |
| 286 | //! *started* and never that one had ended. |
| 287 | //! |
| 288 | //! Found by asking how a screen distinguishes groups of settings by colour, and |
| 289 | //! the answer turned out to be two findings rather than one. This is the first |
| 290 | //! and it is the precondition: there is nothing to tint until there is a |
| 291 | //! container. The second — every renderer already resolves `category.one` |
| 292 | //! through `category.six` and no description can reach any of them — is filed |
| 293 | //! and not shipped here. |
| 294 | //! |
| 295 | //! What the colour question settled anyway, because it shapes this member: the |
| 296 | //! group carries no colour and no ordinal. A renderer distinguishing sibling |
| 297 | //! groups derives the assignment from their order, which is |
| 298 | //! [`Region::Columns`]' reasoning about counts applied to colour — the children |
| 299 | //! say, and a value here would be a second source for something the description |
| 300 | //! already states by containing them. |
| 301 | //! |
| 302 | //! 0.28.0 is what audiofiles' forms port found it could not say, three findings |
| 303 | //! filed against a working conversion rather than guessed at in advance. All |
| 304 | //! three are about a *question* rather than about a control, which is the line |
| 305 | //! this crate keeps having to redraw. |
| 306 | //! |
| 307 | //! - [`FieldKind::Range`] and [`Field::step`]. A bounded number the user drags |
| 308 | //! across, where both ends being on screen is what the question means. The |
| 309 | //! reading to resist is that this is [`FieldKind::Number`] with bounds, and it |
| 310 | //! is [`FieldKind::Radio`]'s argument again: a validated number can be out of |
| 311 | //! range and a slider cannot, so the bounds stop being a rule and become the |
| 312 | //! control's extent. [`Field::bounded`] is the check a renderer asks, since a |
| 313 | //! range missing an end has nothing to draw. |
| 314 | //! - [`Choice::unavailable`]. An option that is real, worth showing, and cannot |
| 315 | //! be picked yet. Without it an app either drops the option — and the user |
| 316 | //! never learns it is there — or hand-rolls the control outside the |
| 317 | //! description, which is what audiofiles' instrument panel did: a permanently |
| 318 | //! disabled radio plus a hand-written line saying what would enable it. |
| 319 | //! `#[non_exhaustive]` arrives on [`Choice`] in the same release, so this is |
| 320 | //! the last breaking addition to it. |
| 321 | //! - Not a member at all: [`Field::placeholder`] on a chooser. It was sayable |
| 322 | //! already and no renderer read it, so a select with nothing chosen showed an |
| 323 | //! empty box and the instruction lived on a disabled button elsewhere. The |
| 324 | //! renderers moved, not the description. |
| 325 | //! |
| 326 | //! 0.29.1 adds [`Awaiting`], which is the sentence [`Readiness`] could say about |
| 327 | //! a region and could not say about a control. A described screen could state |
| 328 | //! that a list was on its way and could not state that the button just pressed |
| 329 | //! is doing the thing it was pressed for, so every renderer's in-flight |
| 330 | //! treatment was the app's to hand-write. The MNW server hand-writes it 57 times |
| 331 | //! and hand-writes the guard against a second press twice, which is the half |
| 332 | //! that matters going missing on a codebase that sells things. |
| 333 | //! |
| 334 | //! The mark is the fact that something outstanding will complete, once, in |
| 335 | //! expected finite time. Deliberately not remoteness, since a heavy local query |
| 336 | //! waits too, and deliberately not slowness, which is a judgement rather than a |
| 337 | //! property. It carries an optional amount, stated only when the amount is |
| 338 | //! measured, and it carries no duration at all: a renderer draws what is done |
| 339 | //! over what there is plus the time so far, and never an estimate of what is |
| 340 | //! left. |
| 341 | //! |
| 342 | //! One mark and two readings, which is what keeps a slow region from being |
| 343 | //! hand-split into its own route the way MNW's payout summary is: a pressed |
| 344 | //! control goes busy and locks, a region fed by an awaiting call stands in as |
| 345 | //! [`Readiness::Pending`] and fills when it lands. |
| 346 | //! |
| 347 | //! A patch release for a new member, which is the 0.27.5 precedent rather than a |
| 348 | //! new rule: nothing existing changed shape, so every consumer already asking |
| 349 | //! for 0.29 keeps resolving and the suite below this crate does not have to move |
| 350 | //! for a type only quasi reads. The minor releases above were minor because they |
| 351 | //! also narrowed something. |
| 352 | //! |
| 353 | //! 0.30.0 is two members batched into one release, which is 0.11.0's precedent |
| 354 | //! and its reasoning: pre-1.0 a minor is breaking, the cascade below this crate |
| 355 | //! is seven repos, and paying that twice in a week for two unrelated words is |
| 356 | //! the tax the batching exists to avoid. |
| 357 | //! |
| 358 | //! - [`FieldKind::Rich`], a field whose value is markdown source. The editing |
| 359 | //! counterpart of prose already carried as markdown, and it is renderable |
| 360 | //! everywhere for the reason the carrying is: editing markdown is editing |
| 361 | //! text. It buys a renderer permission to offer a preview or a syntax pass and |
| 362 | //! buys a host reading the value back the knowledge of what it holds; a |
| 363 | //! renderer with neither draws a textarea. It says nothing about when the |
| 364 | //! value is saved, because autosave is a clock. Measured against four MNW |
| 365 | //! section editors that are one shape written four times. |
| 366 | //! [`FieldKind::multiline`] arrives with it, since the pair is now two members |
| 367 | //! every renderer has to ask about. |
| 368 | //! - [`Facet`], [`Selecting`], [`FacetValue`] and [`Standing`]: a named |
| 369 | //! dimension a set is narrowed by. MNW's discover page filters six ways |
| 370 | //! through six mechanisms, and its filter rows carry a tick box *and* a |
| 371 | //! chevron only because a tag's selection and a tag's browse position were |
| 372 | //! held separately. One word covers all six, and [`Selecting::Subtree`] is the |
| 373 | //! member that made it an enum rather than a bool: a tree's selection is |
| 374 | //! branches taken and branches pruned, which no flat mode can express, and |
| 375 | //! making one gesture do browsing and filtering together is what lets the |
| 376 | //! second mechanism go. [`Standing`] has four members rather than a bool for |
| 377 | //! the tree's sake — a value in force because an ancestor is, is not a value |
| 378 | //! somebody picked. [`FacetValue`] splits an identifier from a label for |
| 379 | //! [`Choice`]'s reason and one of its own: two leaves under different parents |
| 380 | //! are legitimately both called "Ambient", and the path is what tells them |
| 381 | //! apart and what nearest-ancestor-wins resolves over. Deliberately wider than |
| 382 | //! that one page: audiofiles' library browser and goingson's filters are the |
| 383 | //! same shape. |
| 384 | //! |
| 385 | //! 0.31.0 finishes the file field. [`FieldKind::File`] arrived at 0.11.0 |
| 386 | //! carrying neither an accepted-types list nor a multiplicity flag, and said so |
| 387 | //! in its own doc: `accept` appeared at zero sites in either app, and a member |
| 388 | //! added for a case nobody has is a member designed against nothing. That count |
| 389 | //! was taken over goingson and Balanced Breakfast, and the MNW server is a third |
| 390 | //! consumer with 14 `accept` lists across 10 templates and 4 of its 16 file |
| 391 | //! inputs marked `multiple`. The reasoning was right and the measurement went |
| 392 | //! stale, so [`Field::accept`] and [`Field::multiple`] arrive now. |
| 393 | //! |
| 394 | //! - [`Accepted`] is an enum rather than the comma-joined string the templates |
| 395 | //! hold, because the list is read twice and only one of the readings is |
| 396 | //! filtering. The other is which disclosure to offer — a preview, a duration, |
| 397 | //! a waveform — and a renderer deciding that from raw strings is three |
| 398 | //! renderers each writing a media-type parser. [`Accepted::family`] answers it |
| 399 | //! once. All three shapes are in the measured sites and none can be dropped: |
| 400 | //! `image/*` is a [`Family`], `image/jpeg` and `text/csv` are a |
| 401 | //! [`Type`](Accepted::Type), and `.zip`, `.tar.gz` and `.clap` are a |
| 402 | //! [`Suffix`](Accepted::Suffix). One site carries `.csv,text/csv`, which is |
| 403 | //! both in one list. |
| 404 | //! - A suffix carries no family and this crate will not infer one. `.mp3` is |
| 405 | //! audio in fact, and a table here saying so is a mapping that rots in a |
| 406 | //! published crate and is wrong for the first container format someone hands |
| 407 | //! it. A call site that wants the disclosure writes the family or the media |
| 408 | //! type, which is what the sites offering previews already do. |
| 409 | //! - There is one upload shape, not one per type. What a media upload shows |
| 410 | //! beyond a plain one is disclosure layered on this shape, which is why the |
| 411 | //! accept list is load-bearing beyond validation and why nothing here names a |
| 412 | //! media upload as its own kind. |
| 413 | //! - Progress is not a member and needs none. An upload in flight is a control |
| 414 | //! in flight with a number attached, so it is [`Awaiting`] with the file's |
| 415 | //! length as its [`amount`](Awaiting::amount) — the case that type's own doc |
| 416 | //! names. Where the bytes go is an address, and this crate holds none; that is |
| 417 | //! the router's [`Action`], which the field already points at when it writes |
| 418 | //! on its own. |
| 419 | //! |
| 420 | //! # Reach, focus and the focus ring |
| 421 | //! |
| 422 | //! Three terms, and no others, for what 0.19.0 moved out of the description. |
| 423 | //! **Reach** is which things can take focus and in what order; a browser reads |
| 424 | //! it off the document, a TUI derives it from draw order, egui from its own id |
| 425 | //! stack. **Focus** is which reached thing has the keyboard right now: the |
| 426 | //! renderer's, live, never described and never round-tripped through a |
| 427 | //! description. The **focus ring** is the visible cue; the token (`focus-ring`, |
| 428 | //! derived by `makeover` from the action colour) is the one shared artifact and |
| 429 | //! the drawing is the renderer's. Retired as names for any of this: "focus |
| 430 | //! stroke", "focus cue", "wants focus". "Caret" is a different thing — the text |
| 431 | //! cursor inside a field — and keeps its name. |
| 432 | //! |
| 433 | //! # The three tones, and what a colour claims |
| 434 | //! |
| 435 | //! One rule, settled 2026-08-16, for how colour says whether a thing can be |
| 436 | //! used. Every renderer answers to it, and it is stated here because the |
| 437 | //! description is what names the intents. |
| 438 | //! |
| 439 | //! | the thing | intent | |
| 440 | //! |-----------|--------| |
| 441 | //! | active, emphasised, the thing itself | `content` | |
| 442 | //! | inactive but usable: it still answers a press | `content-secondary` | |
| 443 | //! | inert: disabled, or not a control at all | `content-muted` | |
| 444 | //! |
| 445 | //! `content-muted` is the one with a claim in it. [`State::Disabled`] resolves |
| 446 | //! to it, so a live control wearing it is telling the user it will not answer — |
| 447 | //! and being wrong about that is worse than being quiet, because the user's |
| 448 | //! response is to stop trying. A sortable column heading that was never sorted, |
| 449 | //! and every unchosen option in a radio group, both read as dead lists that way; |
| 450 | //! those are the two this rule was written out of. What is legitimately muted is |
| 451 | //! a caption, a hint, a placeholder, a meter's reading, an axis label: text that |
| 452 | //! was never going to answer anything. |
| 453 | //! |
| 454 | //! The three are one ramp and not three colours. `makeover`'s `Emphasis` derives |
| 455 | //! the quieter two from the ink, so "one step back" means the same distance in |
| 456 | //! every theme and a renderer cannot land between them by picking its own. |
| 457 | //! |
| 458 | //! # First paint is final paint |
| 459 | //! |
| 460 | //! One rule, settled 2026-08-16. Nothing may change size or position after it is |
| 461 | //! first drawn, and nothing may stand in for content that has not arrived yet. |
| 462 | //! Both halves are absolute. |
| 463 | //! |
| 464 | //! It is stated here, rather than left to each renderer, because a renderer can |
| 465 | //! only reserve space the description gave it enough to size. A member whose |
| 466 | //! size depends on its content therefore owes whatever makes it sizeable while |
| 467 | //! the content is still absent, and that is the second admission test for a new |
| 468 | //! member: not only does it compose something this crate already names, it can |
| 469 | //! be laid out before it is filled. |
| 470 | //! |
| 471 | //! The mechanism is a reservation, and [`Sort`]'s caret is the worked example. |
| 472 | //! The caret is drawn into a box its own width whether or not the column is |
| 473 | //! sorted, so pressing a heading cannot reflow the row it sits in. The box names |
| 474 | //! no magnitude, which is what keeps it out of `makeover-geometry`'s territory. |
| 475 | //! Reserve from what is known; never discover geometry from what has not |
| 476 | //! arrived. |
| 477 | //! |
| 478 | //! The trap is an `Option` that means "not yet". [`Readiness::Pending`] is the |
| 479 | //! honest way to say a region is still waiting. An optional *measurement* is |
| 480 | //! not: a count that shows up later widens the text that prints it and moves |
| 481 | //! everything beside it, which is the reflow this rule exists to forbid. So an |
| 482 | //! `Option` on a measurement means the host will never know it — a property of |
| 483 | //! the query, fixed for the life of the screen — and a renderer sizes for the |
| 484 | //! answer it was handed rather than for the one it hopes is coming. |
| 485 | //! |
| 486 | //! # Any width, one answer |
| 487 | //! |
| 488 | //! The sibling of the rule above, and settled the same day. That one is |
| 489 | //! independence from *when*; this one is independence from *how you got here*. |
| 490 | //! |
| 491 | //! A rendering is a pure function of the description and the viewport. The same |
| 492 | //! description at the same width is the same output, whatever widths came |
| 493 | //! before it. No renderer may carry geometry across frames, and none may narrow |
| 494 | //! by counting. |
| 495 | //! |
| 496 | //! The failure this forbids is ordinary enough to be the default everywhere |
| 497 | //! else: a page that hides its sidebar below some width, remembers that it hid |
| 498 | //! it, and does not bring it back the same way. Layout there is a function of |
| 499 | //! `(width, history)`, so dragging a window to 900 wide is a different screen |
| 500 | //! depending on whether you came from 1400 or from 600. Nobody chose that; it |
| 501 | //! is what measuring and remembering produce. |
| 502 | //! |
| 503 | //! The mechanism is [`Width`] for what grows and [`Priority`] for what drops. |
| 504 | //! Both are declared, both are read off the description, and neither needs a |
| 505 | //! measurement. A renderer narrows by raising a cutoff over a total order, |
| 506 | //! never by counting what fits and stopping — `makeover-tui`'s table states |
| 507 | //! that as its own rule and tests it, and `makeover-webview` reaches the same |
| 508 | //! place with `@media` and `display: none`, which is path-independent by |
| 509 | //! construction because CSS has nowhere to keep the previous width. |
| 510 | //! |
| 511 | //! Two things follow for anything new. A member that would need last frame's |
| 512 | //! size to lay out this frame is refused, the same way a member that cannot be |
| 513 | //! sized before it is filled is refused. And a fact about what disappears |
| 514 | //! belongs in the description, because a host that has to infer it can only |
| 515 | //! infer it from a measurement. |
| 516 | //! |
| 517 | //! # Where the description stops |
| 518 | //! |
| 519 | //! The rule is that a member is added when an app needs a fact the vocabulary |
| 520 | //! cannot state, and refused when what it wants is presentation it should be |
| 521 | //! asking a renderer for. That is the whole test. It is not a quota, and the |
| 522 | //! goal is every screen described. |
| 523 | //! |
| 524 | //! ## What the timeline refusal got wrong, 2026-08-15 |
| 525 | //! |
| 526 | //! This section used to read "a day-plan timeline, a kanban board and a |
| 527 | //! calendar are not describable here and will not become describable", and it |
| 528 | //! propagated: 12 files across three apps, three libraries and the design wiki |
| 529 | //! cited it, including audiofiles and the MNW server, neither of which has a |
| 530 | //! timeline. It is withdrawn, and [`Track`] is the member it was refusing. |
| 531 | //! |
| 532 | //! The error was pricing. The argument assumed a timeline needs a component |
| 533 | //! library's worth of vocabulary, and nobody measured it. Held against |
| 534 | //! goingson's `day-planning-render.js`, the members it actually needed and |
| 535 | //! could not get were two integers: where a thing starts, and how long it |
| 536 | //! lasts. Labels, gridlines, item bodies and tones were all furniture this |
| 537 | //! crate already named. A refusal that expensive should have carried a |
| 538 | //! measurement, and did not. |
| 539 | //! |
| 540 | //! The reasoning underneath it survives and is still the test: slot heights, |
| 541 | //! gridline colour, how overlapping things stack, which hour scrolls into view. |
| 542 | //! Those are presentation, they stay the renderer's, and [`Track`] carries none |
| 543 | //! of them. What changed is the conclusion, not the principle. |
| 544 | //! |
| 545 | //! ## The other two, measured 2026-08-15 |
| 546 | //! |
| 547 | //! The same sentence refused a kanban board and a calendar. Both were counted |
| 548 | //! the way the timeline should have been, and neither came out where the |
| 549 | //! refusal put it. |
| 550 | //! |
| 551 | //! **Kanban: one member, and it is [`Region::Columns`].** Held against |
| 552 | //! goingson's `tasks-kanban.js`, every card fact was already sayable — title, |
| 553 | //! project, due date, the blocked and unblocks badges, subtask progress, the |
| 554 | //! open action and the context menu are `Row`'s existing parts. A column is a |
| 555 | //! heading, a count and a list. What nothing could say was that the columns are |
| 556 | //! *peers*: [`Arrangement`] offers list-detail and sidebar-content, and a board |
| 557 | //! described as either is a lie about the screen. Dragging a card between |
| 558 | //! columns never entered into it — a drop's effect is "set status", a discrete |
| 559 | //! action `Row`'s menu already carries, and the drag itself is affordance. |
| 560 | //! |
| 561 | //! **Calendar: no members, no consumer, and a sharper reason (Max, |
| 562 | //! 2026-08-15).** The month grid's primacy in calendar apps is an artifact of |
| 563 | //! paper: paper cannot be queried, so it has to show every day at once as a |
| 564 | //! fallback index. Routes, search and ranking do that job better, which is the |
| 565 | //! argument `events-calendar.js` already lost to a segmented list on |
| 566 | //! 2026-08-11. |
| 567 | //! |
| 568 | //! Three jobs survive that reasoning, and only one of them needs a grid: |
| 569 | //! |
| 570 | //! 1. **Spans across days** — a stretch of leave, a trip, a sprint. You cannot |
| 571 | //! see "away the 3rd to the 17th" in a list without diffing dates. This is |
| 572 | //! [`Track`] with [`Unit::Days`], not a calendar, and |
| 573 | //! [`Track::days`] is it. |
| 574 | //! 2. **Density at a glance** — which weeks were heavy. That is a heatmap, and |
| 575 | //! goingson describes both of its heatmaps as lists already. |
| 576 | //! 3. **Weekday periodicity** — "every other Tuesday", "the 15th is a |
| 577 | //! Saturday". This is the only job that needs the seven-column wrap, because |
| 578 | //! alignment is the whole of what makes it visible. |
| 579 | //! |
| 580 | //! So the open question is not "is a calendar describable" but "is job 3 worth |
| 581 | //! a member", and nothing in the tree asks for job 3 yet. GoingsOn |
| 582 | //! quasicoherent `4a1237b6`. |
| 583 | //! |
| 584 | //! A month grid renders today as a |
| 585 | //! [`Table`](crate::Column): seven weekday columns, weeks as rows, blanks for |
| 586 | //! the offset. goingson's monthly review reached this conclusion before this |
| 587 | //! note did and describes its month as a list of days that had something on |
| 588 | //! them, marking today with an ordinary badge. What the tree actually contains |
| 589 | //! is two completion heatmaps — one scalar per day — and no calendar at all: |
| 590 | //! `events-calendar.js` was deleted 2026-08-11 in favour of a segmented list, |
| 591 | //! and no MNW template mentions one. So the refusal was defending a screen |
| 592 | //! nobody has. If one is built, measure again; the facts already fit and only |
| 593 | //! the grid's shape would be in question. |
| 594 | //! |
| 595 | //! The pattern worth keeping from all three: one sentence refused three things |
| 596 | //! for one reason, and the reason was wrong three different ways. Count the |
| 597 | //! members. |
| 598 | //! |
| 599 | //! [`Region::Bespoke`] remains for the genuinely app-owned, and its |
| 600 | //! justification does not depend on the withdrawn claim. The |
| 601 | //! description names the *place* and the app owns the contents, so a screen |
| 602 | //! containing a timeline is still a whole screen and still routable. Without |
| 603 | //! it, the four goingson screens that make the app worth using would need a |
| 604 | //! second, undescribed path beside the router, and two paths is how a |
| 605 | //! vocabulary starts drifting from its app again. |
| 606 | //! |
| 607 | //! [`Region::Widget`] sits between that limit and the primitives, and it does |
| 608 | //! not move the limit. A widget is an assembly of members this crate *already* |
| 609 | //! has, under a name a renderer may or may not recognise. Anything that needs a |
| 610 | //! member the vocabulary does not have is still a finding about the vocabulary |
| 611 | //! or still bespoke; naming an assembly buys no new expressive power, which is |
| 612 | //! exactly why it is safe to let the set grow outside this crate. |
| 613 | |
| 614 | |
| 615 | |
| 616 | /// A colour intent this crate refers to but never resolves. |
| 617 | /// |
| 618 | /// The string is the token name `makeover` publishes, so a renderer can look |
| 619 | /// it up without this crate knowing what colour came back. |
| 620 | |
| 621 | /// The `makeover` intent token this resolves against. |
| 622 | ; |
| 623 | |
| 624 | |
| 625 | /// Which way the light falls across a two-tone edge. |
| 626 | /// |
| 627 | /// The whole content of a bevel, once colour and thickness are deferred. The |
| 628 | /// light is always assumed to come from the top left: every consumer measured |
| 629 | /// agreed on that and none of them ever varied it, so it is an invariant here |
| 630 | /// rather than a parameter. |
| 631 | /// |
| 632 | /// # The two corners that belong to both edges |
| 633 | /// |
| 634 | /// Top-right and bottom-left are where the lit run meets the shaded one, and |
| 635 | /// the description's claim is that they belong to *both*. How a renderer says |
| 636 | /// that is its own business, because the answer is bounded by resolution and |
| 637 | /// not by taste: |
| 638 | /// |
| 639 | /// - A terminal cell is roughly 8x17 device pixels, so giving the whole corner |
| 640 | /// to one tone thickens that edge by a cell and reads as one run overrunning |
| 641 | /// the other. A half-cell glyph divides the cell already, so `makeover-tui` |
| 642 | /// splits it and recovers real information. Its box-drawing fallback cannot: |
| 643 | /// a single stroke has no half to give, so there both corners go to dark. |
| 644 | /// - A pixel bevel is a one-point stroke by default, which makes the corner a |
| 645 | /// one-point square. There is nothing to divide — a diagonal seam across one |
| 646 | /// point is sub-pixel, and antialiasing renders it as the blend a mitred join |
| 647 | /// already produces. So `makeover-immediate` mitres and is *not* diverging; |
| 648 | /// it is the same rule at a resolution where the split degenerates. |
| 649 | /// |
| 650 | /// Stated here so the difference reads as a decision rather than as drift. A |
| 651 | /// renderer with room to divide the corner should; one without should mitre or |
| 652 | /// pick the shaded tone, and neither is a bug. |
| 653 | |
| 654 | |
| 655 | /// Lit from the top left: light on top and left, dark on bottom and right. |
| 656 | Raised, |
| 657 | /// The same edge inverted, which is also the pressed state of anything |
| 658 | /// that draws itself [`Bevel::Raised`]. |
| 659 | Inset, |
| 660 | |
| 661 | |
| 662 | |
| 663 | /// The edge intents, as `(top_left, bottom_right)`. |
| 664 | /// |
| 665 | /// Split out from any painting because the inversion *is* the idea, and |
| 666 | /// it is the one part every renderer implements identically. |
| 667 | |
| 668 | pub const |
| 669 | match self |
| 670 | SelfRaised => , |
| 671 | SelfInset => , |
| 672 | |
| 673 | |
| 674 | |
| 675 | /// Pressing inverts. A raised control reads as inset while held. |
| 676 | /// |
| 677 | /// Stated here rather than left to each consumer because a cascade can |
| 678 | /// carry a pressed state and an immediate-mode renderer cannot: audiofiles |
| 679 | /// resolves this per call site, eighteen times. |
| 680 | |
| 681 | pub const |
| 682 | match self |
| 683 | SelfRaised => SelfInset, |
| 684 | SelfInset => SelfRaised, |
| 685 | |
| 686 | |
| 687 | |
| 688 | |
| 689 | /// One side of a bevel, named by the intent it takes. |
| 690 | |
| 691 | |
| 692 | /// The lit side. |
| 693 | Light, |
| 694 | /// The shadowed side. |
| 695 | Dark, |
| 696 | |
| 697 | |
| 698 | |
| 699 | |
| 700 | match self |
| 701 | SelfLight => "bevel-light", |
| 702 | SelfDark => "bevel-dark", |
| 703 | |
| 704 | |
| 705 | |
| 706 | |
| 707 | /// A surface intent a region is filled with. |
| 708 | /// |
| 709 | /// `#[non_exhaustive]`, so a renderer must carry a wildcard arm and a new |
| 710 | /// member is additive rather than breaking. Added 0.4.0, after [`Sunken`] |
| 711 | /// (an additive member, 0.3.0) hard-broke `makeover-tui` and |
| 712 | /// `makeover-immediate` at compile time and left neither able to move until |
| 713 | /// both published. The vocabulary exists to grow and the renderers exist to |
| 714 | /// disagree about how much of it they answer, so growth must not be a |
| 715 | /// lockstep event. The renderer's wildcard is not a hole: [`Fill`] is |
| 716 | /// resolved through a fallible lookup, and a missing intent is answered with |
| 717 | /// structure rather than with a substituted colour. |
| 718 | /// |
| 719 | /// [`Sunken`]: Fill::Sunken |
| 720 | |
| 721 | |
| 722 | |
| 723 | /// The page behind everything. |
| 724 | Page, |
| 725 | /// A surface lifted off the page: cards, controls, menus, toasts. |
| 726 | Raised, |
| 727 | /// A surface floating above the page rather than resting on it. |
| 728 | Overlay, |
| 729 | /// The inside of a well. |
| 730 | Well, |
| 731 | /// A surface set back from the one it sits on, by colour and nothing else. |
| 732 | /// |
| 733 | /// Not a well. A well is a hole with an edge, and the two are authored in |
| 734 | /// opposite directions: `makeover` derives `surface-well` by inverting |
| 735 | /// against the theme's own content colour, while `surface-sunken` is |
| 736 | /// authored and free to sit darker than raised (goingson's does). Naming |
| 737 | /// only the well left the recessed-with-no-edge surface unsayable, which is |
| 738 | /// what an unchosen tab is: it recedes so the chosen one can come forward, |
| 739 | /// and it carries no bevel of its own. |
| 740 | /// |
| 741 | /// Added 0.3.0, from goingson's tab strip, which hand-writes exactly this |
| 742 | /// and could not delete the line because no member described it. |
| 743 | Sunken, |
| 744 | |
| 745 | |
| 746 | // No `fallback` here, deliberately. An earlier cut had `Fill::Well` fall back |
| 747 | // to `Fill::Page` so a consumer on makeover 2.2.0, which has no `surface-well`, |
| 748 | // had something to paint. makeover-tui found that wrong within a day: page is |
| 749 | // the surface a well is usually cut into, so on a terminal that substitution |
| 750 | // produces exactly the invisibility it was meant to prevent, and the right |
| 751 | // answer there is a drawn edge rather than a different colour. |
| 752 | // |
| 753 | // Substituting one intent for another is renderer policy. The description says |
| 754 | // what the region is and stops. |
| 755 | |
| 756 | |
| 757 | |
| 758 | match self |
| 759 | SelfPage => "surface-page", |
| 760 | SelfRaised => "surface-raised", |
| 761 | SelfOverlay => "surface-overlay", |
| 762 | SelfWell => "surface-well", |
| 763 | SelfSunken => "surface-sunken", |
| 764 | |
| 765 | |
| 766 | |
| 767 | |
| 768 | /// How a region sits relative to the surface behind it. |
| 769 | /// |
| 770 | /// Fill and bevel are named together because naming them apart is what let |
| 771 | /// them disagree. Every consumer measured had at least one region carrying a |
| 772 | /// raised bevel over a recessed fill: audiofiles fixed it in `raised_frame` |
| 773 | /// and recorded the bug in its doc comment, and Balanced Breakfast still had |
| 774 | /// twelve of them a year later. A single name for the pair makes that |
| 775 | /// unrepresentable. |
| 776 | /// `#[non_exhaustive]` for the same reason as [`Fill`], and in the same |
| 777 | /// release: a depth this renderer has no drawing for should cost it a |
| 778 | /// wildcard arm, not a compile error and a wait on someone else's publish. |
| 779 | |
| 780 | |
| 781 | |
| 782 | /// Level with its surroundings. No edge. |
| 783 | Flat, |
| 784 | /// A card laid on the panel it sits in. |
| 785 | Raised, |
| 786 | /// A hole in the panel, with content down inside it. For anything the |
| 787 | /// user looks *into*: a table body, a tag tree, a text field. |
| 788 | Well, |
| 789 | /// Set back from what it sits on, by colour alone. No edge. |
| 790 | /// |
| 791 | /// The one member carrying a fill without a bevel, so a renderer cannot |
| 792 | /// assume the two arrive together. That is deliberate and it is still the |
| 793 | /// pairing rule: both halves come off the same `Depth`, so they cannot |
| 794 | /// disagree, and here one half is legitimately absent. |
| 795 | /// |
| 796 | /// Distinct from [`Depth::Flat`], which has no fill either and inherits. |
| 797 | /// Recessed and level-with are different claims, and only one of them |
| 798 | /// needs a colour. |
| 799 | Sunken, |
| 800 | /// A surface sitting *over* the page rather than in it. A modal, a popover, |
| 801 | /// a menu. |
| 802 | /// |
| 803 | /// Takes elevation and no bevel: a surface overlaying the page is lifted |
| 804 | /// off it, and a surface in the page is cut into it. That is the same |
| 805 | /// pairing rule the rest of the enum holds, applied to the one case where |
| 806 | /// the separation is not an edge at all — the lift and the scrim behind it |
| 807 | /// are already saying where the surface is. |
| 808 | /// |
| 809 | /// Every renderer had the surface before it had this variant. |
| 810 | /// `makeover-tui` carries `Palette::overlay`, `makeover-immediate` gained |
| 811 | /// `Palette::elevation` at 0.10.0, and `makeover-webview` emits |
| 812 | /// `--elevation-overlay`. What was missing was the route from a description |
| 813 | /// to any of them, which is why this is one variant rather than a feature. |
| 814 | Overlay, |
| 815 | |
| 816 | |
| 817 | |
| 818 | /// The edge this depth is drawn with, if it has one. |
| 819 | |
| 820 | pub const |
| 821 | match self |
| 822 | // Sunken joins Flat here, for the opposite reason: Flat has no edge |
| 823 | // because nothing separates it from its surroundings, and Sunken has |
| 824 | // none because its colour is already doing the separating. |
| 825 | SelfFlat | SelfSunken => None, |
| 826 | // A third reason to have no edge, which is why it gets its own arm |
| 827 | // rather than joining the two above: an overlay is separated by the |
| 828 | // lift and by the scrim behind it, so an edge would be a second |
| 829 | // answer to a question already answered. |
| 830 | SelfOverlay => None, |
| 831 | SelfRaised => Some, |
| 832 | SelfWell => Some, |
| 833 | |
| 834 | |
| 835 | |
| 836 | /// The surface this depth is filled with. |
| 837 | /// |
| 838 | /// [`Depth::Flat`] has no fill of its own: it inherits whatever it sits on, |
| 839 | /// which is the difference between level-with and painted-the-same-colour. |
| 840 | |
| 841 | pub const |
| 842 | match self |
| 843 | SelfFlat => None, |
| 844 | SelfRaised => Some, |
| 845 | SelfWell => Some, |
| 846 | SelfSunken => Some, |
| 847 | SelfOverlay => Some, |
| 848 | |
| 849 | |
| 850 | |
| 851 | /// Pressing a raised region reads as a well, and nothing else moves. |
| 852 | /// |
| 853 | /// [`Depth::Overlay`] is untouched along with the rest: an overlay is a |
| 854 | /// surface, not a control, so there is nothing there to press. |
| 855 | |
| 856 | pub const |
| 857 | match self |
| 858 | SelfRaised => SelfWell, |
| 859 | other => other, |
| 860 | |
| 861 | |
| 862 | |
| 863 | |
| 864 | /// An interaction state a region can be in, beside whatever [`Depth`] it is. |
| 865 | /// |
| 866 | /// Orthogonal to depth on purpose. A disabled button is still [`Depth::Raised`] |
| 867 | /// and a disabled field is still a [`Depth::Well`], so folding either member |
| 868 | /// into `Depth` would make [`Depth::bevel`] and [`Depth::fill`] answer for |
| 869 | /// something that is not a depth, and would leave disabled-button and |
| 870 | /// disabled-field sharing one variant that cannot tell them apart. |
| 871 | /// |
| 872 | /// # Why hover and pressed are not members |
| 873 | /// |
| 874 | /// The line is whether every renderer has the state to express, not whether CSS |
| 875 | /// does. Hover is renderer policy and `makeover-webview` says so in its own |
| 876 | /// header: a terminal and an immediate-mode painter have no pointer hovering |
| 877 | /// over anything, and pressed already arrives through [`Bevel::pressed`] and |
| 878 | /// [`Depth::pressed`], where it belongs, because pressing is a depth inversion |
| 879 | /// rather than a separate condition. |
| 880 | /// |
| 881 | /// Focus and disabled are different in kind. A TUI has a focused widget and a |
| 882 | /// greyed-out one; so does egui. Both were unsayable here, so all three webview |
| 883 | /// consumers supplied them from outside the primitive by out-specifying rules |
| 884 | /// they did not own: goingson alone carries 19 of them, and the MNW server |
| 885 | /// another 21. That is the divergence this crate exists to end, arriving one |
| 886 | /// layer down. |
| 887 | /// |
| 888 | /// # The principle this encodes |
| 889 | /// |
| 890 | /// A primitive owns every state it implies. A renderer that emits a hover rule |
| 891 | /// for a thing owes disabled and the capability answer for that same thing, |
| 892 | /// because anything less exports the completion work to N consumers who will |
| 893 | /// each do it differently. |
| 894 | /// |
| 895 | /// Focus is not on that list and was removed from this axis in 0.19.0. It is |
| 896 | /// the renderer's, decided after the description; see the crate header, "Reach, |
| 897 | /// focus and the focus ring", for the three terms and who owns each. |
| 898 | /// |
| 899 | /// `#[non_exhaustive]` for the reason [`Fill`] and [`Depth`] carry it: growth |
| 900 | /// must not be a lockstep event across the three renderers. |
| 901 | |
| 902 | |
| 903 | |
| 904 | /// Present, visible, and not answering. |
| 905 | /// |
| 906 | /// Not the same as absent, and deliberately not a [`Fill`]: a disabled |
| 907 | /// control keeps the surface it always had and stops responding, so what |
| 908 | /// changes is its content and its interactivity rather than what it is. |
| 909 | Disabled, |
| 910 | |
| 911 | |
| 912 | |
| 913 | /// Whether a region in this state stops answering the pointer. |
| 914 | /// |
| 915 | /// Stated in the description rather than left to each renderer, on the same |
| 916 | /// reasoning as [`Bevel::pressed`]: a cascade carries it for free and an |
| 917 | /// immediate-mode renderer resolves it per call site, so leaving it unsaid |
| 918 | /// means resolving it once per consumer and disagreeing. |
| 919 | |
| 920 | pub const |
| 921 | // A match rather than a bare `true`, so a member added to this |
| 922 | // `#[non_exhaustive]` axis has to answer the question rather than |
| 923 | // inheriting an answer. |
| 924 | match self |
| 925 | SelfDisabled => true, |
| 926 | |
| 927 | |
| 928 | |
| 929 | |
| 930 | |
| 931 | |
| 932 | match self |
| 933 | // Reusing the muted content intent rather than minting a |
| 934 | // `disabled` colour. Disabled is a reduction and not a status, and |
| 935 | // `makeover-webview`'s progress rules already record the reading |
| 936 | // that `content-muted` is what disabled looks like. |
| 937 | SelfDisabled => "content-muted", |
| 938 | |
| 939 | |
| 940 | |
| 941 | |
| 942 | /// What a region is saying, when it is saying something. |
| 943 | /// |
| 944 | /// The one intent family shared by badges, notices and nothing else. Kept |
| 945 | /// separate from [`Fill`] because a surface is where a thing sits and a tone is |
| 946 | /// what it means, and the three apps agree on the four statuses: |
| 947 | /// `info_banner` / `warning_banner` in audiofiles, `.toast-info` / |
| 948 | /// `.toast-success` / `.toast-error` in goingson, `.toast.success` / |
| 949 | /// `.toast.error` in Balanced Breakfast. |
| 950 | /// |
| 951 | /// The per-tag palette (`category-one` through `category-six`) is deliberately |
| 952 | /// not here. Which colour a *particular* tag takes is app domain, and both |
| 953 | /// webview apps already carry it as a `data-color` attribute. |
| 954 | |
| 955 | |
| 956 | /// No status. Reads as ordinary de-emphasised content. |
| 957 | Neutral, |
| 958 | /// Something worth knowing and nothing to do about it. |
| 959 | Info, |
| 960 | /// Something finished and it worked. |
| 961 | Success, |
| 962 | /// Something the user should look at before continuing. |
| 963 | Warning, |
| 964 | /// Something broken, or something about to be destroyed. |
| 965 | Danger, |
| 966 | |
| 967 | |
| 968 | |
| 969 | |
| 970 | match self |
| 971 | // Neutral has no status token of its own. It takes the muted |
| 972 | // content intent, which is what both webview apps already spell as |
| 973 | // `data-color="muted"`. |
| 974 | SelfNeutral => "content-muted", |
| 975 | SelfInfo => "info", |
| 976 | SelfSuccess => "success", |
| 977 | SelfWarning => "warning", |
| 978 | SelfDanger => "danger", |
| 979 | |
| 980 | |
| 981 | |
| 982 | |
| 983 | /// A small labelled thing that sits inside something else. |
| 984 | /// |
| 985 | /// Two members, because the three apps drew three taxonomies and only one line |
| 986 | /// runs through all of them: does it answer a click. audiofiles has |
| 987 | /// `classification_badge` (a label) against `tag_chip`, `tag_chip_removable` |
| 988 | /// and `selectable_tag` (all of which do). Balanced Breakfast has `.tag` and |
| 989 | /// `.badge` against `.tag-chip`. goingson is the one that has to move: its |
| 990 | /// `.tag` and `.badge` are a single CSS rule, so every call site has to be read |
| 991 | /// to decide which of the two it always was. |
| 992 | /// |
| 993 | /// The evidence that a chip is a real concept rather than a badge with a |
| 994 | /// cursor: audiofiles inverts its bevel on press and Balanced Breakfast latches |
| 995 | /// `.tag-chip.active` with the inset bevel. Two independent arrivals at "a chip |
| 996 | /// holds itself down", which is exactly what [`Depth::pressed`] already says. |
| 997 | |
| 998 | |
| 999 | /// Non-interactive status or count. Answers no click. |
| 1000 | Badge, |
| 1001 | /// An interactive or removable token. Answers a click, and latches if it |
| 1002 | /// stands for a filter that is either on or off. |
| 1003 | Chip |
| 1004 | /// Whether it carries its own remove affordance. |
| 1005 | removable: bool, |
| 1006 | , |
| 1007 | |
| 1008 | |
| 1009 | |
| 1010 | /// Whether this answers a click. |
| 1011 | /// |
| 1012 | /// The whole difference between the two members, and the reason a renderer |
| 1013 | /// with no hover (a touch surface, a terminal) can still tell them apart. |
| 1014 | |
| 1015 | pub const |
| 1016 | matches! |
| 1017 | |
| 1018 | |
| 1019 | /// How it sits, given whether it is currently latched down. |
| 1020 | /// |
| 1021 | /// A badge is flat: it is a label, and giving it an edge would say it can |
| 1022 | /// be pressed. A chip is raised, and inset while latched. |
| 1023 | |
| 1024 | pub const |
| 1025 | match self |
| 1026 | SelfBadge => Flat, |
| 1027 | SelfChip if latched => Well, |
| 1028 | SelfChip => Raised, |
| 1029 | |
| 1030 | |
| 1031 | |
| 1032 | |
| 1033 | /// Something the app is telling the user, unprompted. |
| 1034 | /// |
| 1035 | /// Two concepts, not one with a placement. They differ in more than where they |
| 1036 | /// sit: a toast is transient, stacked and self-dismissing, and a banner is |
| 1037 | /// persistent, in flow, one per region, and dismissed by fixing the condition |
| 1038 | /// it reports. Folding them into one member with a placement parameter would |
| 1039 | /// make lifetime, stacking and dismissal all placement-dependent, which is the |
| 1040 | /// description leaking renderer policy. |
| 1041 | /// |
| 1042 | /// All three apps have banners: `info_banner` and `warning_banner` in |
| 1043 | /// audiofiles, five of them in goingson (sync, sync-result, vacation-day, |
| 1044 | /// timer-active, past-review), `.update-banner` in Balanced Breakfast. The two |
| 1045 | /// webview apps also have toasts. So neither member is speculative, and no app |
| 1046 | /// gains a concept it lacks except audiofiles, whose renderer may legitimately |
| 1047 | /// decline to draw a toast at all. |
| 1048 | |
| 1049 | |
| 1050 | /// Transient, stacked, dismisses itself. |
| 1051 | Toast, |
| 1052 | /// Persistent, in flow, one per region, dismissed by fixing the cause. |
| 1053 | Banner, |
| 1054 | |
| 1055 | |
| 1056 | |
| 1057 | /// Whether it goes away on its own. |
| 1058 | |
| 1059 | pub const |
| 1060 | matches! |
| 1061 | |
| 1062 | |
| 1063 | /// How it sits. |
| 1064 | /// |
| 1065 | /// A toast floats above the page rather than resting on it, which is |
| 1066 | /// [`Fill::Overlay`]'s whole reason to exist. A banner is a card in the |
| 1067 | /// flow. Both are raised, and they are raised off different things. |
| 1068 | |
| 1069 | pub const |
| 1070 | match self |
| 1071 | SelfToast => Overlay, |
| 1072 | SelfBanner => Raised, |
| 1073 | |
| 1074 | |
| 1075 | |
| 1076 | |
| 1077 | /// The parts of a list row. |
| 1078 | /// |
| 1079 | /// Four to begin with, taken from Balanced Breakfast, which was the only |
| 1080 | /// consumer that had all of them (`row-primary`, `row-secondary`, `row-meta`, |
| 1081 | /// `row-actions`). audiofiles has two and no slot structure at all, so it gains |
| 1082 | /// meta and actions as real work rather than a rename; goingson moves off |
| 1083 | /// `task-row` / `task-cell`. |
| 1084 | /// |
| 1085 | /// [`Tokens`](Self::Tokens) joined at 0.9.0, and `#[non_exhaustive]` with it. |
| 1086 | /// See the crate header for why the two arrived together. |
| 1087 | /// |
| 1088 | /// # Meta against Tokens |
| 1089 | /// |
| 1090 | /// The line is whether the thing has its own standing. `Meta` is one short |
| 1091 | /// trailing fact about the row, written as text: a count, a size, a date. |
| 1092 | /// `Tokens` is a set of small labelled things, each of which can be toned and |
| 1093 | /// can answer a click. "3 files" is meta. A status badge that is amber, and a |
| 1094 | /// tag you can click to filter by, are tokens. |
| 1095 | /// |
| 1096 | /// Keeping them apart is what a single widened slot would have foreclosed. A |
| 1097 | /// renderer can right-align one string and cannot usefully do the same to a |
| 1098 | /// strip of chips, and a fact that is not clickable should not be drawn as |
| 1099 | /// though it were. |
| 1100 | /// How much vertical room a part's text may take. |
| 1101 | /// |
| 1102 | /// A row is an inline run and every part in it is a leaf, so a part's text has |
| 1103 | /// always been drawn on one line and no description could say otherwise. Two |
| 1104 | /// apps say otherwise in their own stylesheets, both to the same number and |
| 1105 | /// both with a comment explaining it: Balanced Breakfast clamps a feed row's |
| 1106 | /// title to two lines (`.row--article .row-primary`, whose comment reads |
| 1107 | /// "overrides .row-primary's single flex line"), and goingson clamps a |
| 1108 | /// problem's body to two ("two lines is enough to recognize one, and the full |
| 1109 | /// text is in the task once promoted"). |
| 1110 | /// |
| 1111 | /// Two named tiers rather than a line count, and the count is what the measured |
| 1112 | /// demand argues against. Both sites want exactly one tier past the default, |
| 1113 | /// and a number invites a row whose primary is a paragraph, which is a block |
| 1114 | /// and has no business in a run. A third tier is a decision, made here, rather |
| 1115 | /// than something a call site can reach for. |
| 1116 | /// |
| 1117 | /// What a renderer owes it: `Tight` is what a run already does and needs no |
| 1118 | /// answer. `Relaxed` is at most two lines and then truncation, however that |
| 1119 | /// renderer truncates -- a webview clamps, a terminal wraps into two rows of |
| 1120 | /// cells, an immediate-mode renderer caps the galley. A renderer that cannot |
| 1121 | /// give two lines may draw one; what it may not do is grow without bound, |
| 1122 | /// because the run is a line and the row's neighbours are relying on that. |
| 1123 | |
| 1124 | |
| 1125 | |
| 1126 | /// One line. What every part did before this type existed. |
| 1127 | |
| 1128 | Tight, |
| 1129 | /// Up to two lines, then truncated. |
| 1130 | Relaxed, |
| 1131 | |
| 1132 | |
| 1133 | |
| 1134 | /// How many lines the part may take. |
| 1135 | /// |
| 1136 | /// A number here rather than in the enum, because a renderer needs one and |
| 1137 | /// a call site does not. That asymmetry is the whole argument for the |
| 1138 | /// tiers: the description says how much room the thing deserves and this |
| 1139 | /// says what that costs, so a third tier changes one line rather than every |
| 1140 | /// consumer's arithmetic. |
| 1141 | |
| 1142 | pub const |
| 1143 | match self |
| 1144 | SelfRelaxed => 2, |
| 1145 | // Including any tier added later: one line is the safe reading of |
| 1146 | // an unknown flow, since it is what the run guaranteed before flows |
| 1147 | // existed. |
| 1148 | _ => 1, |
| 1149 | |
| 1150 | |
| 1151 | |
| 1152 | |
| 1153 | |
| 1154 | |
| 1155 | |
| 1156 | /// The thing itself. What the row is called. |
| 1157 | Primary, |
| 1158 | /// Supporting text under the primary. |
| 1159 | Secondary, |
| 1160 | /// A short trailing fact: a count, a size, a date. |
| 1161 | Meta, |
| 1162 | /// Controls that act on this row. |
| 1163 | Actions, |
| 1164 | /// Small labelled things belonging to the row: badges, chips, tags. |
| 1165 | /// |
| 1166 | /// Each carries its own [`Token`] kind and [`Tone`], so a renderer with no |
| 1167 | /// colour still has the kind to work with, and one with no chips still has |
| 1168 | /// the label. That is the constrained-consumer test this vocabulary exists |
| 1169 | /// to pass, and it is why the tone lives on the token rather than on the |
| 1170 | /// part. |
| 1171 | Tokens, |
| 1172 | /// How much of a set the row's thing has done: a [`Meter`] in the row. |
| 1173 | /// |
| 1174 | /// Added 0.11.0, `da5666ae`, and it is [`Tokens`](Self::Tokens)'s problem |
| 1175 | /// again with a different payload. [`Meter`] arrived at 0.10.0 and closed |
| 1176 | /// two of the seven sites that asked for it; the other five sit in rows, and |
| 1177 | /// a row holds no nodes by the ruling that a row part may not carry an |
| 1178 | /// arbitrary node — the door through which a description becomes a |
| 1179 | /// templating language. So the part carries the *description of a bar* |
| 1180 | /// rather than a node, exactly as `Tokens` carries tags rather than nodes. |
| 1181 | /// |
| 1182 | /// Without it a row flattens the proportion into [`Meta`](Self::Meta) as |
| 1183 | /// "3/7 subtasks", which keeps both numbers and loses the reading, the same |
| 1184 | /// way a toned status badge read as prose before `Tokens`. |
| 1185 | Proportion, |
| 1186 | |
| 1187 | |
| 1188 | |
| 1189 | /// What the part is worth when the run does not fit. |
| 1190 | /// |
| 1191 | /// The default only. A part may say otherwise, and a renderer reads the |
| 1192 | /// part rather than the role; this is what a description that has never |
| 1193 | /// heard of [`Priority`] means, which is every description written before |
| 1194 | /// the field existed. |
| 1195 | /// |
| 1196 | /// Deriving it from the role is the thing this vocabulary has otherwise |
| 1197 | /// been moving away from, and it is right here for one reason: the roles |
| 1198 | /// already encode this ranking and every consumer already assumes it. |
| 1199 | /// [`Primary`](Self::Primary) is what the row is called, and |
| 1200 | /// [`Priority::Essential`]'s own doc was written about exactly that -- |
| 1201 | /// "without it the row does not identify itself". |
| 1202 | /// |
| 1203 | /// [`Actions`](Self::Actions) is `Essential` and it is the interesting one. |
| 1204 | /// A control is not a fact, so dropping it does not cost the reader a |
| 1205 | /// detail; it costs them the only way to act on the row, and in a terminal |
| 1206 | /// it silently removes something focus had already been claimed for. A |
| 1207 | /// renderer that needs room takes it from what the row *says*, never from |
| 1208 | /// what it *offers*. |
| 1209 | /// |
| 1210 | /// An unknown member reads as [`Priority::Secondary`]: droppable, but not |
| 1211 | /// first, since guessing `Optional` for something this crate has not been |
| 1212 | /// taught would make a new member the first thing to vanish. |
| 1213 | |
| 1214 | pub const |
| 1215 | match self |
| 1216 | SelfPrimary | SelfActions => Essential, |
| 1217 | SelfMeta | SelfProportion => Optional, |
| 1218 | _ => Secondary, |
| 1219 | |
| 1220 | |
| 1221 | |
| 1222 | /// The content intent the part takes. |
| 1223 | |
| 1224 | pub const |
| 1225 | match self |
| 1226 | SelfPrimary => "content", |
| 1227 | SelfSecondary => "content-secondary", |
| 1228 | SelfMeta => "content-muted", |
| 1229 | // Actions carry controls rather than text, so they inherit. |
| 1230 | SelfActions => "content", |
| 1231 | // So do tokens: each one carries its own tone, and a part-level |
| 1232 | // intent underneath it would fight the token that sits on it. |
| 1233 | SelfTokens => "content", |
| 1234 | // And so does a proportion, for the same reason: the meter carries |
| 1235 | // the tone, and it is about the ratio rather than about the row. |
| 1236 | SelfProportion => "content", |
| 1237 | |
| 1238 | |
| 1239 | |
| 1240 | |
| 1241 | /// How far down the heading tree a title sits. |
| 1242 | /// |
| 1243 | /// Three, and only the three that are actually headings. The bands those used |
| 1244 | /// to be filed with (goingson's `.page-header`, Balanced Breakfast's `.header` |
| 1245 | /// and `.detail-header`) are arrangement, not type, and live at |
| 1246 | /// [`Region::Band`]. One of them contains no text at all. |
| 1247 | |
| 1248 | |
| 1249 | /// Names the whole screen. One per screen. |
| 1250 | Page, |
| 1251 | /// Names a block within the screen. |
| 1252 | Section, |
| 1253 | /// Names a sub-block inside an already-named section. |
| 1254 | Subsection, |
| 1255 | |
| 1256 | |
| 1257 | |
| 1258 | /// Whether a rule follows the heading. |
| 1259 | /// |
| 1260 | /// audiofiles' `section_header` draws a separator and its |
| 1261 | /// `subsection_label` deliberately does not, which is the only thing |
| 1262 | /// distinguishing the two once weight and colour are deferred. |
| 1263 | |
| 1264 | pub const |
| 1265 | matches! |
| 1266 | |
| 1267 | |
| 1268 | |
| 1269 | /// A control that picks between things. |
| 1270 | /// |
| 1271 | /// Three, because three distinct behaviours are in play and collapsing any two |
| 1272 | /// loses something. A segmented control picks a value; a tab picks a pane; a |
| 1273 | /// toggle picks nothing and simply holds itself on or off. |
| 1274 | |
| 1275 | |
| 1276 | /// Exactly one of N, and the options abut. |
| 1277 | Segmented, |
| 1278 | /// Independent on or off, on its own. |
| 1279 | Toggle, |
| 1280 | /// Navigation between panes. The folder semantic. |
| 1281 | Tabs, |
| 1282 | |
| 1283 | |
| 1284 | |
| 1285 | /// How the chosen option sits. |
| 1286 | /// |
| 1287 | /// Held in for a segmented control and a toggle, which is the same shape |
| 1288 | /// pressing produces and the whole economy of the idiom: one appearance, |
| 1289 | /// two reasons to wear it. A tab is the exception, because the selected |
| 1290 | /// folder tab comes *forward* to join the pane it opens. |
| 1291 | |
| 1292 | pub const |
| 1293 | match self |
| 1294 | SelfSegmented | SelfToggle => Well, |
| 1295 | SelfTabs => Raised, |
| 1296 | |
| 1297 | |
| 1298 | |
| 1299 | /// How the options that were *not* picked sit. |
| 1300 | /// |
| 1301 | /// Added 0.3.0. Describing only [`Selector::chosen`] left the unchosen |
| 1302 | /// option falling through to [`Depth::Flat`], which says it is level with |
| 1303 | /// the strip it sits in, and no renderer emitted anything for it. That is |
| 1304 | /// wrong in both directions and goingson proved it: its unchosen tabs are |
| 1305 | /// recessed by hand, and being recessed is *why* the chosen one reads as |
| 1306 | /// coming forward. Against a flat strip, a raised chosen tab is a bevel |
| 1307 | /// drawn on the strip's own colour, which is a much weaker folder effect |
| 1308 | /// than the contrast the idiom is named after. |
| 1309 | /// |
| 1310 | /// Each member is the inverse of its chosen state, which is the whole |
| 1311 | /// content of "picked" once colour is deferred: |
| 1312 | /// |
| 1313 | /// - Tabs recede, so the chosen one comes forward. |
| 1314 | /// - A segment and a toggle stand up, so the chosen one is held in. |
| 1315 | |
| 1316 | pub const |
| 1317 | match self |
| 1318 | SelfTabs => Sunken, |
| 1319 | SelfSegmented | SelfToggle => Raised, |
| 1320 | |
| 1321 | |
| 1322 | |
| 1323 | /// Whether the options touch. |
| 1324 | /// |
| 1325 | /// The gap is the entire difference between a segmented control and a row |
| 1326 | /// of buttons that happen to sit near each other, which is what audiofiles' |
| 1327 | /// `segmented_control` says in its own comment and why it zeroes the |
| 1328 | /// spacing by hand. |
| 1329 | |
| 1330 | pub const |
| 1331 | matches! |
| 1332 | |
| 1333 | |
| 1334 | |
| 1335 | /// What is in a region right now. |
| 1336 | /// |
| 1337 | /// The state, not the shimmer. Whether pending paints a skeleton, a spinner or |
| 1338 | /// nothing at all is renderer policy, the same class of decision that got |
| 1339 | /// `Fill::fallback` deleted from this crate. goingson and Balanced Breakfast |
| 1340 | /// each grew a skeleton with differently-named parts; both keep them, as the |
| 1341 | /// webview renderer's expression of [`Readiness::Pending`]. audiofiles has none |
| 1342 | /// and needs none, because an immediate-mode renderer simply repaints. |
| 1343 | /// |
| 1344 | /// # Four states and not two, as of 0.12.0 |
| 1345 | /// |
| 1346 | /// `703f4cd2`. It named `Ready` and `Pending` and stopped, so a described screen |
| 1347 | /// whose list came back empty had to render an empty region or invent its own |
| 1348 | /// placeholder text, and neither says what it is. goingson draws one at 27 sites |
| 1349 | /// across 12 files and Balanced Breakfast at 9, with a class family that had |
| 1350 | /// already drifted into `empty-state`, `empty-state--error`, `error-state` and |
| 1351 | /// six more. |
| 1352 | /// |
| 1353 | /// The four are one axis because they are mutually exclusive: a region shows its |
| 1354 | /// content, or a sign that it is coming, or a sign that there is none, or a sign |
| 1355 | /// that it broke. Never two. That is the test for one enum against several |
| 1356 | /// fields, and it is why this grew rather than a new member arriving beside it. |
| 1357 | /// |
| 1358 | /// # What is not here |
| 1359 | /// |
| 1360 | /// **The message.** "No projects yet" is content, and this names a state. It |
| 1361 | /// lives with whatever holds the region — in quasi's case a `Slot` — alongside |
| 1362 | /// the action that leads out of the emptiness, since an address is the one thing |
| 1363 | /// this crate never names. |
| 1364 | /// |
| 1365 | /// **How much room it gets.** goingson's `--compact`, `--dashboard` and |
| 1366 | /// `--padded` are the same state at three sizes, and a size is |
| 1367 | /// `makeover-geometry`'s question. Naming them here would be this crate stating |
| 1368 | /// values again. |
| 1369 | /// |
| 1370 | /// **The icon.** Presentation, and each host has its own answer or none. |
| 1371 | |
| 1372 | |
| 1373 | |
| 1374 | /// The content is here. |
| 1375 | Ready, |
| 1376 | /// The content is on its way. |
| 1377 | /// |
| 1378 | /// For a region that changes *after* the first paint, and never for the |
| 1379 | /// first paint itself: see "First paint is final paint" in the crate header. |
| 1380 | /// A host that renders once, with its data already in hand, has nothing to |
| 1381 | /// say this about, and a screen arriving in this state is describing a |
| 1382 | /// moment its host should not have been in. |
| 1383 | /// |
| 1384 | /// What stands in occupies the geometry the content will occupy. A stand-in |
| 1385 | /// sized to itself rather than to what replaces it is the reflow the rule |
| 1386 | /// forbids, arriving one repaint later. |
| 1387 | Pending, |
| 1388 | /// The content arrived and there is none of it. |
| 1389 | /// |
| 1390 | /// Not a failure. An empty list is the normal state of a new install, and a |
| 1391 | /// renderer that drew it in a danger tone would be reporting a fault where |
| 1392 | /// there is none. |
| 1393 | Empty, |
| 1394 | /// The content did not arrive. |
| 1395 | Failed, |
| 1396 | |
| 1397 | |
| 1398 | |
| 1399 | /// Whether the region draws its own content, or something standing in for |
| 1400 | /// it. |
| 1401 | /// |
| 1402 | /// The question every renderer asks first, so it is answered once here |
| 1403 | /// rather than by a `matches!` in each. A state added later is a stand-in |
| 1404 | /// until proven otherwise: falling back to drawing content that may not be |
| 1405 | /// there is the worse of the two mistakes. |
| 1406 | |
| 1407 | pub const |
| 1408 | matches! |
| 1409 | |
| 1410 | |
| 1411 | /// What the state means, for a renderer choosing a colour. |
| 1412 | /// |
| 1413 | /// Derived rather than carried, which is the opposite of [`Meter`] and |
| 1414 | /// [`Figure`], and the difference is worth stating: a proportion's meaning |
| 1415 | /// depends on what is being counted and only the app knows it, while |
| 1416 | /// "nothing here yet" and "this broke" mean the same thing in every app that |
| 1417 | /// will ever have them. |
| 1418 | |
| 1419 | pub const |
| 1420 | match self |
| 1421 | SelfFailed => Danger, |
| 1422 | _ => Neutral, |
| 1423 | |
| 1424 | |
| 1425 | |
| 1426 | |
| 1427 | /// An action is waiting on something that resolves once, in expected finite |
| 1428 | /// time. |
| 1429 | /// |
| 1430 | /// The control-side sibling of [`Readiness`]. That enum names four states for a |
| 1431 | /// region and named nothing at all for the button that is currently doing what |
| 1432 | /// it was clicked for, so the in-flight treatment is hand-written wherever it |
| 1433 | /// exists: the MNW server carries 57 in-flight indicators against 2 guards |
| 1434 | /// against a second press, which is the spinner mostly present and the guard |
| 1435 | /// mostly absent, on a codebase whose money path is a purchase button. |
| 1436 | /// |
| 1437 | /// # What is described here, and what is not |
| 1438 | /// |
| 1439 | /// The fact is that there is an outstanding thing which will complete. Not that |
| 1440 | /// the address is remote: a heavy local query waits too, and a server calling a |
| 1441 | /// payment provider is not the browser leaving the app. Not that the call is |
| 1442 | /// slow either, which is a judgement about a call rather than a property of one. |
| 1443 | /// |
| 1444 | /// Resolving **once** is the boundary, and it is what separates this from a |
| 1445 | /// screen that keeps changing. A live screen never resolves and has no name in |
| 1446 | /// this crate yet. |
| 1447 | /// |
| 1448 | /// # One mark, two renderings |
| 1449 | /// |
| 1450 | /// | what reads it | what it does | |
| 1451 | /// |---|---| |
| 1452 | /// | a control that was pressed | goes busy and refuses a second press until it resolves | |
| 1453 | /// | a region fed by it | stands in as [`Readiness::Pending`], then fills | |
| 1454 | /// |
| 1455 | /// The two were on the table separately and both were taken. Controls alone |
| 1456 | /// leaves a slow region hand-split into its own route, which is what MNW's user |
| 1457 | /// dashboard does with its payout summary; regions alone leaves the purchase |
| 1458 | /// button unguarded. |
| 1459 | /// |
| 1460 | /// # A quantity when it is measured, never a duration |
| 1461 | /// |
| 1462 | /// [`amount`](Self::amount) is stated only when it is a measured fact about the |
| 1463 | /// payload. An upload's file length, yes; a round trip to a payment provider, |
| 1464 | /// [`None`]. A duration is described nowhere, and a renderer may not manufacture |
| 1465 | /// one from the amount either: a determinate bar shows what is done over what |
| 1466 | /// there is, plus the time it has taken so far, and never a remaining time, an |
| 1467 | /// arrival time or a rate extrapolated forwards. A prediction is wrong the |
| 1468 | /// moment the transfer stalls, and being confidently wrong is worse than being |
| 1469 | /// honestly indeterminate. |
| 1470 | /// |
| 1471 | /// This is why the crate refuses to say how long an undo stays offered and |
| 1472 | /// accepts a byte count here. The refusal is about naming a decision that |
| 1473 | /// belongs to the renderer; a file's length is not a decision, nobody chose it. |
| 1474 | /// |
| 1475 | /// # Not [`Meter`] |
| 1476 | /// |
| 1477 | /// [`Meter`] is how much of a set is done, and its own docs refuse the progress |
| 1478 | /// of an operation on the grounds that a description is built once and dropped |
| 1479 | /// while an operation runs between renders. That refusal stands. This names the |
| 1480 | /// operation and its size, which is all that is known before it starts; how much |
| 1481 | /// of it has gone through is the renderer's to observe live, and nothing round |
| 1482 | /// trips through a description to say so. |
| 1483 | |
| 1484 | |
| 1485 | |
| 1486 | /// Total work to get through, when it is a measured fact about the payload. |
| 1487 | /// |
| 1488 | /// `None` when the wait has no countable size, which is the common case and |
| 1489 | /// the default. |
| 1490 | /// |
| 1491 | /// Unit-agnostic on purpose. Bytes for an upload, rows for an import; what |
| 1492 | /// is being counted is the app's business and a renderer draws a proportion |
| 1493 | /// either way. |
| 1494 | pub amount: , |
| 1495 | |
| 1496 | |
| 1497 | |
| 1498 | /// A wait with no countable size. |
| 1499 | |
| 1500 | pub const |
| 1501 | Self |
| 1502 | |
| 1503 | |
| 1504 | /// A wait whose size is known. |
| 1505 | /// |
| 1506 | /// Reach for it only with a measured figure. An estimate written in here is |
| 1507 | /// a prediction wearing a fact's clothes, and the renderer has no way to |
| 1508 | /// tell the two apart. |
| 1509 | |
| 1510 | pub const |
| 1511 | Self |
| 1512 | amount: Some, |
| 1513 | |
| 1514 | |
| 1515 | |
| 1516 | /// Whether there is a proportion to draw. |
| 1517 | /// |
| 1518 | /// The question every renderer asks first, answered once here rather than by |
| 1519 | /// a `matches!` in each. False means indeterminate, which is the honest |
| 1520 | /// drawing when nothing countable was measured. |
| 1521 | |
| 1522 | pub const |
| 1523 | self.amount.is_some |
| 1524 | |
| 1525 | |
| 1526 | |
| 1527 | /// How much of a set is done. |
| 1528 | /// |
| 1529 | /// Added 0.10.0. Nine sites across the two webview apps drew a bar and nothing |
| 1530 | /// here named one, so every described screen concatenated the two numbers into |
| 1531 | /// its heading text instead: "Subtasks 3/7", "Time Tracking 45m tracked / 30m |
| 1532 | /// est, over". Every fact survives that and the reading does not, which is the |
| 1533 | /// same loss `RowPart::Tokens` closed when a toned status badge became prose. |
| 1534 | /// |
| 1535 | /// # Why a pair and not a percentage |
| 1536 | /// |
| 1537 | /// Both numbers, not the percentage the apps compute from them. The percentage |
| 1538 | /// was the obvious shape and it had already been tried: goingson's |
| 1539 | /// `Task::time_progress` divides, rounds, and then clamps to 100, which throws |
| 1540 | /// away the one case the bar exists to show — 45 minutes tracked against a |
| 1541 | /// 30-minute estimate. It carries a separate `is_over_estimate` boolean beside |
| 1542 | /// it to recover the fact the clamp dropped. A pair keeps the over-run without a |
| 1543 | /// companion flag, and [`percent`](Meter::percent) is still one call away for a |
| 1544 | /// renderer that wants it. |
| 1545 | /// |
| 1546 | /// The pair is also what the apps already have at every site. All seven |
| 1547 | /// determinate bars write the ratio into the accessible layer and never the |
| 1548 | /// percentage: `title="3/7 subtasks"`, `aria-label="3 of 7 subtasks completed"`, |
| 1549 | /// a milestone's own `3/7` span. Given 43 nothing can recover "3 of 7", so a |
| 1550 | /// percentage member would have made [`label`](Meter::label) mandatory at every |
| 1551 | /// call site, which is the concatenated text this member removes, moved one |
| 1552 | /// layer down. |
| 1553 | /// |
| 1554 | /// # What this is not |
| 1555 | /// |
| 1556 | /// The progress of an *operation*. Two of the nine sites are that — goingson's |
| 1557 | /// focus timer, Balanced Breakfast's feed fetch — and they get nothing here, on |
| 1558 | /// purpose. Both are imperative controllers over a live handle, driven by a tick |
| 1559 | /// or an event stream, and a description is built once and dropped. Holding one |
| 1560 | /// would mean growing a way to update a description between renders, which is a |
| 1561 | /// different feature. [`Readiness::Pending`] and a [`Notice::Toast`] carry the |
| 1562 | /// honest part. |
| 1563 | /// |
| 1564 | /// The two cases are distinguishable in the markup rather than by taste: every |
| 1565 | /// determinate bar in both apps carries a tone, and neither operation bar |
| 1566 | /// carries one. Two codebases drew that line the same way without coordinating. |
| 1567 | |
| 1568 | |
| 1569 | /// How much is done. May exceed [`total`](Self::total), and that is the |
| 1570 | /// case worth drawing. |
| 1571 | pub done: u32, |
| 1572 | /// How much there is to do. Zero means there is no set, not that the set is |
| 1573 | /// complete. |
| 1574 | pub total: u32, |
| 1575 | /// What the proportion means right now. |
| 1576 | /// |
| 1577 | /// Carried rather than derived, because no renderer can work it out. The |
| 1578 | /// same 90% is [`Tone::Success`] on a subtask rollup and [`Tone::Danger`] on |
| 1579 | /// a time estimate, and goingson picks between them from `is_over_estimate`, |
| 1580 | /// a fact about the data and not about the number. |
| 1581 | pub tone: Tone, |
| 1582 | /// What is being counted, if the bar says so: "subtasks", "tasks". |
| 1583 | /// |
| 1584 | /// The noun, not the ratio. A renderer builds "3 of 7 subtasks" from this |
| 1585 | /// and the two numbers; handing it the assembled string would put the |
| 1586 | /// sentence order in the description, where a terminal at one line and a |
| 1587 | /// tooltip want different ones. |
| 1588 | pub label: , |
| 1589 | |
| 1590 | |
| 1591 | |
| 1592 | /// A proportion with no tone and no label. |
| 1593 | |
| 1594 | pub const |
| 1595 | Self |
| 1596 | done, |
| 1597 | total, |
| 1598 | tone: Neutral, |
| 1599 | label: None, |
| 1600 | |
| 1601 | |
| 1602 | |
| 1603 | /// What the proportion means. |
| 1604 | |
| 1605 | pub const |
| 1606 | self.tone = tone; |
| 1607 | self |
| 1608 | |
| 1609 | |
| 1610 | /// What is being counted. |
| 1611 | |
| 1612 | pub const |
| 1613 | self.label = Some; |
| 1614 | self |
| 1615 | |
| 1616 | |
| 1617 | /// How full the bar is, 0 to 100, clamped. |
| 1618 | /// |
| 1619 | /// For drawing, which is the only thing a clamped number is good for. Ask |
| 1620 | /// [`overflowing`](Self::overflowing) before reporting it as a fact, or this |
| 1621 | /// is `time_progress`'s bug again with the clamp moved. |
| 1622 | /// |
| 1623 | /// An empty set reads as 0. Nothing is done, because there is nothing to do |
| 1624 | /// and no bar to fill; the apps guard on the count before drawing at all. |
| 1625 | |
| 1626 | pub const |
| 1627 | if self.total == 0 |
| 1628 | return 0; |
| 1629 | |
| 1630 | let scaled = / self.total as u64; |
| 1631 | if scaled > 100 else |
| 1632 | |
| 1633 | |
| 1634 | /// Whether more is done than there was to do. |
| 1635 | /// |
| 1636 | /// The fact [`percent`](Self::percent) destroys, kept reachable so a |
| 1637 | /// renderer can mark the over-run rather than drawing a full bar and |
| 1638 | /// implying it landed exactly. |
| 1639 | |
| 1640 | pub const |
| 1641 | self.done > self.total |
| 1642 | |
| 1643 | |
| 1644 | /// Whether there is a set at all. |
| 1645 | /// |
| 1646 | /// A meter over nothing is sayable on purpose, for the same reason a field |
| 1647 | /// with no options is: it is what an app with an unloaded count actually |
| 1648 | /// has, and a renderer that shows an empty bar says so on screen rather than |
| 1649 | /// dividing by zero. |
| 1650 | |
| 1651 | pub const |
| 1652 | self.total == 0 |
| 1653 | |
| 1654 | |
| 1655 | |
| 1656 | /// One figure with a caption: a number and what it counts. |
| 1657 | /// |
| 1658 | /// The dashboard shape. A large value over a small caption, several of them in a |
| 1659 | /// strip: a current streak, a completion rate, a total. Added 0.11.0, |
| 1660 | /// `93c6a174`, after goingson turned out to have five of them across five |
| 1661 | /// screens with five class vocabularies for the one shape — `task-overview-stat`, |
| 1662 | /// `stat-box`, `month-stat-item`, `contact-summary-stat`, `sync-stat`. Four put |
| 1663 | /// the value above the caption and one inverts it, which is drift inside the |
| 1664 | /// shape rather than a second shape. |
| 1665 | /// |
| 1666 | /// # Why the value is text |
| 1667 | /// |
| 1668 | /// "17", "84%", "12/30", "3d". A figure is whatever the app computed, already |
| 1669 | /// formatted, and the formatting is the app's because only it knows whether the |
| 1670 | /// number is a percentage, a duration or a ratio. This carries none of the |
| 1671 | /// arithmetic [`Meter`] carries, and that is the difference between them: a |
| 1672 | /// meter is a proportion a renderer draws, and a figure is a fact a renderer |
| 1673 | /// sets in type. |
| 1674 | /// |
| 1675 | /// # Tone is carried, for [`Meter`]'s reason |
| 1676 | /// |
| 1677 | /// Three of the five sites tone the figure by their own means — `red`/`blue` on |
| 1678 | /// the weekly review, a `${type}` class on the monthly one, `sync-stat-warn` on |
| 1679 | /// sync. So tone is carried at every site that needs it and derived at none, and |
| 1680 | /// no renderer can work out that a streak of zero is worth colouring. |
| 1681 | /// |
| 1682 | /// # What is not here |
| 1683 | /// |
| 1684 | /// Whether the figure answers a click. One of the five is a control — sync's |
| 1685 | /// "Not Applied: 3" opens the list — and an action is not something this crate |
| 1686 | /// can name: nothing here knows what a route is. That belongs beside the figure |
| 1687 | /// in whatever layer holds the actions, the same way a row's activation sits |
| 1688 | /// beside its parts rather than inside them. |
| 1689 | /// |
| 1690 | /// The arrangement is not here either. Several figures in a strip is a set, and |
| 1691 | /// a renderer given them one at a time cannot tell it is looking at one; the |
| 1692 | /// layer that holds the tree is where the set gets said. |
| 1693 | |
| 1694 | |
| 1695 | /// The number, formatted the way the app means it to read. |
| 1696 | pub value: &'a str, |
| 1697 | /// What it counts. The caption under the value. |
| 1698 | pub caption: &'a str, |
| 1699 | /// How the value has moved, if the app is tracking that. |
| 1700 | /// |
| 1701 | /// Added 0.13.0. Text, for [`value`](Self::value)'s reason: only the app |
| 1702 | /// knows whether a move reads as `+12.5%`, `+3` or `2x`, and a renderer |
| 1703 | /// handed a number would have to guess. |
| 1704 | /// |
| 1705 | /// This is what [`tone`](Self::tone) was for and had no consumer of. The MNW |
| 1706 | /// server has four screens whose stat card is a label, a value and a delta, |
| 1707 | /// and the delta is the toned part: the figure itself is an ordinary fact |
| 1708 | /// and it is the movement that reads as good or bad. Without this the delta |
| 1709 | /// has to be folded into the caption, which loses the tone and reads as a |
| 1710 | /// longer caption rather than as a second, smaller line. |
| 1711 | pub change: , |
| 1712 | /// What the figure means right now. [`Tone::Neutral`] is an ordinary fact. |
| 1713 | /// |
| 1714 | /// Applies to [`change`](Self::change) where there is one, since that is the |
| 1715 | /// part that carries the judgement, and to the value where there is not. |
| 1716 | pub tone: Tone, |
| 1717 | |
| 1718 | |
| 1719 | |
| 1720 | /// A figure that is an ordinary fact. |
| 1721 | |
| 1722 | pub const |
| 1723 | Self |
| 1724 | value, |
| 1725 | caption, |
| 1726 | change: None, |
| 1727 | tone: Neutral, |
| 1728 | |
| 1729 | |
| 1730 | |
| 1731 | /// How the value has moved. |
| 1732 | |
| 1733 | pub const |
| 1734 | self.change = Some; |
| 1735 | self |
| 1736 | |
| 1737 | |
| 1738 | /// What the figure means. |
| 1739 | |
| 1740 | pub const |
| 1741 | self.tone = tone; |
| 1742 | self |
| 1743 | |
| 1744 | |
| 1745 | |
| 1746 | /// Something the user can do, and what it costs to say so. |
| 1747 | /// |
| 1748 | /// Added 0.17.0, out of `quasi-tui`: the terminal renderer had drawn one of |
| 1749 | /// these for months and every other consumer that wanted a button had written |
| 1750 | /// its own, because this layer named [`RowPart::Actions`] as a *slot* and never |
| 1751 | /// named the thing that goes in it. Beside [`Meter`] and [`Figure`] for the |
| 1752 | /// reason those are here: a renderer that is handed the parts has to decide how |
| 1753 | /// to say them, and a renderer that is handed a finished string has already had |
| 1754 | /// the decision made for it. |
| 1755 | /// |
| 1756 | /// No address. Where a control goes is the app's business and every host |
| 1757 | /// follows it differently — an `hx-get`, a protocol URL, a function call — so |
| 1758 | /// the description says what the control *is* and the caller keeps what it |
| 1759 | /// does. That is the same split [`Choice`] makes. |
| 1760 | /// |
| 1761 | /// No confirmation flag either, and that one is a finding rather than an |
| 1762 | /// omission: a question asked *after* a control is pressed belongs to whatever |
| 1763 | /// is holding the interaction, and a renderer that drew it would be asking |
| 1764 | /// before there was anything to answer. |
| 1765 | /// How a picture sits in the box it is given. |
| 1766 | /// |
| 1767 | /// An intent rather than a value, so a renderer picks the expression it has: |
| 1768 | /// `object-fit` in a webview, a texture's UV rect in egui, and in a terminal a |
| 1769 | /// choice about how many cells the blit gets. Named because MNW already makes |
| 1770 | /// the distinction deliberately at 17 sites and makes it three different ways, |
| 1771 | /// which is a policy the app decided rather than one a shared crate would be |
| 1772 | /// picking by accident. |
| 1773 | |
| 1774 | |
| 1775 | |
| 1776 | /// The picture's own proportions, and the box takes the height they imply. |
| 1777 | /// |
| 1778 | /// The default because it is the only one that shows the whole picture at |
| 1779 | /// its own shape, so a renderer that ignores this enum entirely is still |
| 1780 | /// right about the common case. A screenshot wants this; the shipped MNW |
| 1781 | /// carousel sets no `object-fit` at all, which is this. |
| 1782 | |
| 1783 | Natural, |
| 1784 | /// Fill the box and crop whatever does not fit. |
| 1785 | /// |
| 1786 | /// For a picture in a slot whose shape the layout fixed: a thumbnail, an |
| 1787 | /// avatar, cover art. 15 of MNW's 17 sites. |
| 1788 | Cover, |
| 1789 | /// Fit inside the box whole, leaving space on two sides. |
| 1790 | /// |
| 1791 | /// The letterbox. For when the whole picture matters more than filling the |
| 1792 | /// space, and the space is not the picture's shape. |
| 1793 | Contain, |
| 1794 | |
| 1795 | |
| 1796 | /// A picture, and what it says to someone who is not looking at it. |
| 1797 | /// |
| 1798 | /// # No source |
| 1799 | /// |
| 1800 | /// [`Act`]'s split, for [`Act`]'s reason. A source is an address, and this |
| 1801 | /// crate has no notion of an address: it says what a thing *is* and the caller |
| 1802 | /// keeps what it points at. The three findings dropped from 0.11.0 were all |
| 1803 | /// this same shape. |
| 1804 | /// |
| 1805 | /// It matters more here than it does for a control, because a picture is the |
| 1806 | /// one member where the address is most of what a webview needs and *none* of |
| 1807 | /// what the description knows. `quasi_router::Node::Image` carries the URL, the |
| 1808 | /// way it carries an `Action` for a control. |
| 1809 | /// |
| 1810 | /// # Why [`alt`](Self::alt) is not optional |
| 1811 | /// |
| 1812 | /// Every other host has to draw something, and for two of the three the alt |
| 1813 | /// text is not a fallback but the whole rendering: a terminal without a |
| 1814 | /// graphics protocol has the words and nothing else. Making it optional would |
| 1815 | /// make "this picture is invisible on a terminal" the default, and the |
| 1816 | /// description would be carrying a webview assumption in its shape. |
| 1817 | /// |
| 1818 | /// An image that genuinely says nothing — a rule, a spacer, a decoration |
| 1819 | /// repeating what the text beside it already said — is an empty `alt`, which is |
| 1820 | /// the same thing HTML means by it and is a claim rather than an oversight. |
| 1821 | |
| 1822 | |
| 1823 | /// What the picture says, for anything not showing it. |
| 1824 | /// |
| 1825 | /// Empty means the picture is decorative and adds nothing to the text |
| 1826 | /// around it. See the type's own docs on why this is not an `Option`. |
| 1827 | pub alt: &'a str, |
| 1828 | /// A visible line under the picture, where the app wants one. |
| 1829 | /// |
| 1830 | /// Distinct from [`alt`](Self::alt) and the difference is who it is for: a |
| 1831 | /// caption is content everybody reads, alt text is what stands in for the |
| 1832 | /// picture. A screenshot captioned "The library view" still needs alt text |
| 1833 | /// describing what is in the shot. |
| 1834 | pub caption: , |
| 1835 | /// How it sits in the box it is given. |
| 1836 | pub fit: Fit, |
| 1837 | /// The picture's own dimensions, where the app knows them. |
| 1838 | /// |
| 1839 | /// **Not a display size**, and that distinction is what makes this belong |
| 1840 | /// here rather than fall foul of the deferral rule. Saying a picture should |
| 1841 | /// be 320 points wide is a layout value and is not the description's to |
| 1842 | /// give. Saying the file is 5120x3412 is a fact *about the picture*, the |
| 1843 | /// same kind of fact [`alt`](Self::alt) is, and no renderer can find it out |
| 1844 | /// without fetching the bytes. |
| 1845 | /// |
| 1846 | /// # What it is for, and it is not decoration |
| 1847 | /// |
| 1848 | /// Without it a renderer cannot reserve room, so the picture occupies |
| 1849 | /// nothing until it arrives and then takes its full height at once, |
| 1850 | /// shoving everything below it down the screen. Measured on MNW's landing |
| 1851 | /// page 2026-08-14: a 478px jump per frame, and a cumulative layout shift |
| 1852 | /// of 0.087 for the page, which is most of the way to the 0.1 that counts |
| 1853 | /// as bad. |
| 1854 | /// |
| 1855 | /// Every host wants it and none can derive it. A webview writes `width` and |
| 1856 | /// `height` so the browser holds the space; egui sizes a texture; a |
| 1857 | /// terminal with a graphics protocol scales a blit into cells. This was |
| 1858 | /// missing from 0.21.0, which is the release that added [`Image`], and its |
| 1859 | /// absence is the defect rather than an omission. |
| 1860 | /// |
| 1861 | /// `None` is honest and common: a creator-uploaded image whose dimensions |
| 1862 | /// the app never recorded genuinely does not know. It means the renderer |
| 1863 | /// cannot reserve, not that the picture has no size. |
| 1864 | pub intrinsic: , |
| 1865 | /// Whether the picture is needed with the screen, or can arrive later. |
| 1866 | pub loading: Loading, |
| 1867 | |
| 1868 | |
| 1869 | /// A picture's own pixel dimensions. |
| 1870 | /// |
| 1871 | /// Deliberately not [`makeover_geometry`]'s business. Geometry answers *how |
| 1872 | /// much space a thing should get*, which is a scale question with the same |
| 1873 | /// answer on every screen. This is the intrinsic size of one asset, which is a |
| 1874 | /// fact about that asset and varies per picture. |
| 1875 | /// |
| 1876 | /// [`makeover_geometry`]: https://docs.rs/makeover-geometry |
| 1877 | |
| 1878 | |
| 1879 | /// Width in the picture's own pixels. |
| 1880 | pub width: u32, |
| 1881 | /// Height in the picture's own pixels. |
| 1882 | pub height: u32, |
| 1883 | |
| 1884 | |
| 1885 | |
| 1886 | /// A picture's dimensions. |
| 1887 | |
| 1888 | pub const |
| 1889 | Self |
| 1890 | |
| 1891 | |
| 1892 | /// Width over height, or `None` if either side is zero. |
| 1893 | /// |
| 1894 | /// The form a renderer actually reserves space with: a box that knows its |
| 1895 | /// proportion holds the right height at any width, which is what a |
| 1896 | /// responsive picture needs and what a fixed pixel height cannot give. |
| 1897 | |
| 1898 | |
| 1899 | .then |
| 1900 | |
| 1901 | |
| 1902 | |
| 1903 | /// When a picture is needed. |
| 1904 | /// |
| 1905 | /// A claim about *importance and position* rather than a fetch mechanism, which |
| 1906 | /// is why it is the description's to make: only the app knows whether a picture |
| 1907 | /// is the first thing on the screen or the fortieth thing down a list. |
| 1908 | /// |
| 1909 | /// # Eager is the default, and that is a correctness choice |
| 1910 | /// |
| 1911 | /// 0.21.0 emitted the webview's `loading="lazy"` for every picture, on the |
| 1912 | /// evidence that the one consumer measured wrote it. That was reading a habit |
| 1913 | /// as a rule. Deferring a picture that is on screen at first paint does not |
| 1914 | /// save anything -- it is needed immediately either way -- and it delays the |
| 1915 | /// arrival, so the space it eventually takes is claimed later and the shift is |
| 1916 | /// more visible, not less. |
| 1917 | /// |
| 1918 | /// So the safe answer is the default and the optimisation is opted into. A |
| 1919 | /// carousel is the case that proves the two cannot be one setting for the |
| 1920 | /// renderer to choose: its first frame is on screen and its other frames are |
| 1921 | /// not, in the same widget, at the same moment. |
| 1922 | |
| 1923 | |
| 1924 | |
| 1925 | /// Needed with the screen. Fetch it now. |
| 1926 | |
| 1927 | Eager, |
| 1928 | /// Not on screen yet. It can wait until it is near. |
| 1929 | Lazy, |
| 1930 | |
| 1931 | |
| 1932 | |
| 1933 | /// A picture that carries its own proportions. |
| 1934 | |
| 1935 | pub const |
| 1936 | Self |
| 1937 | alt, |
| 1938 | caption: None, |
| 1939 | fit: Natural, |
| 1940 | intrinsic: None, |
| 1941 | loading: Eager, |
| 1942 | |
| 1943 | |
| 1944 | |
| 1945 | /// The picture's own dimensions, so a renderer can hold its place. |
| 1946 | |
| 1947 | pub const |
| 1948 | self.intrinsic = Some; |
| 1949 | self |
| 1950 | |
| 1951 | |
| 1952 | /// This picture is not on screen yet; it can arrive when it is near. |
| 1953 | |
| 1954 | pub const |
| 1955 | self.loading = Lazy; |
| 1956 | self |
| 1957 | |
| 1958 | |
| 1959 | /// A visible line under it. |
| 1960 | |
| 1961 | pub const |
| 1962 | self.caption = Some; |
| 1963 | self |
| 1964 | |
| 1965 | |
| 1966 | /// How it sits in its box. |
| 1967 | |
| 1968 | pub const |
| 1969 | self.fit = fit; |
| 1970 | self |
| 1971 | |
| 1972 | |
| 1973 | /// Whether the picture adds anything for someone not looking at it. |
| 1974 | /// |
| 1975 | /// A renderer with no way to show a picture uses this to decide between |
| 1976 | /// drawing the alt text and drawing nothing at all. Both are correct and |
| 1977 | /// the difference is this flag: standing in for a decorative rule with the |
| 1978 | /// word "decoration" is worse than leaving the space empty. |
| 1979 | |
| 1980 | pub const |
| 1981 | !self.alt.is_empty |
| 1982 | |
| 1983 | |
| 1984 | |
| 1985 | /// What a [`Track`]'s integers count. |
| 1986 | /// |
| 1987 | /// `Track::fraction` never needed this -- the arithmetic is the same whatever |
| 1988 | /// the numbers mean -- which is exactly how the ruler came to assume minutes |
| 1989 | /// and print `00:00` over a month. A renderer drawing an axis has to write a |
| 1990 | /// label, and it cannot derive the unit from the numbers. |
| 1991 | /// |
| 1992 | /// Added 2026-08-15, after a probe put a fifteen-day span on a |
| 1993 | /// thirty-one-slot track and got correct geometry under a wall clock. |
| 1994 | |
| 1995 | |
| 1996 | |
| 1997 | /// Minutes from the start of a day. A day view. |
| 1998 | |
| 1999 | Minutes, |
| 2000 | /// Whole days. A month strip, a sprint, a stretch of leave. |
| 2001 | /// |
| 2002 | /// A day-granularity axis is a *strip*, not a calendar: one line with |
| 2003 | /// spans laid along it. What it deliberately does not do is wrap into |
| 2004 | /// weeks, which is the shape that makes weekday periodicity visible and |
| 2005 | /// the one job of a month grid that a strip cannot take over. See the |
| 2006 | /// crate header. |
| 2007 | Days, |
| 2008 | |
| 2009 | |
| 2010 | /// A window on an axis, in whatever [`Unit`] its [`Track`] counts. |
| 2011 | /// |
| 2012 | /// The axis a [`Track`] draws. Offsets rather than instants, because a |
| 2013 | /// description carrying a `DateTime` would carry a timezone with it and the |
| 2014 | /// vocabulary has no business holding one. The app knows which day or month |
| 2015 | /// this is; the description says how far along it a thing sits. |
| 2016 | /// |
| 2017 | /// `to` is exclusive and may exceed the natural period, which is how a span |
| 2018 | /// running past the end is said without a second date: under |
| 2019 | /// [`Unit::Minutes`], `Span::new(1320, 1560)` is 22:00 to 02:00. |
| 2020 | |
| 2021 | |
| 2022 | from: u16, |
| 2023 | to: u16, |
| 2024 | |
| 2025 | |
| 2026 | |
| 2027 | /// Midnight to midnight, the ordinary day. |
| 2028 | pub const DAY: Self = Self ; |
| 2029 | |
| 2030 | /// A span, clamped to a sane one. |
| 2031 | /// |
| 2032 | /// An empty or backwards span is a caller bug that should not cost a |
| 2033 | /// renderer a division by zero, so `to` is forced at least one minute past |
| 2034 | /// `from` rather than returning an error nobody can act on. Same reasoning |
| 2035 | /// as [`Share::percent`], which clamps rather than refuses. |
| 2036 | |
| 2037 | pub const |
| 2038 | Self |
| 2039 | from, |
| 2040 | to: if to > from else , |
| 2041 | |
| 2042 | |
| 2043 | |
| 2044 | /// The first minute on the axis. |
| 2045 | |
| 2046 | pub const |
| 2047 | self.from |
| 2048 | |
| 2049 | |
| 2050 | /// One past the last minute on the axis. |
| 2051 | |
| 2052 | pub const |
| 2053 | self.to |
| 2054 | |
| 2055 | |
| 2056 | /// How much the axis covers, in its track's unit. Never zero. |
| 2057 | |
| 2058 | pub const |
| 2059 | self.to - self.from |
| 2060 | |
| 2061 | |
| 2062 | /// Whether an offset falls on this axis. |
| 2063 | |
| 2064 | pub const |
| 2065 | minute >= self.from && minute < self.to |
| 2066 | |
| 2067 | |
| 2068 | |
| 2069 | |
| 2070 | |
| 2071 | SelfDAY |
| 2072 | |
| 2073 | |
| 2074 | |
| 2075 | /// Where a thing sits on a [`Track`], and for how long. |
| 2076 | /// |
| 2077 | /// The one fact a list cannot carry and the whole reason this primitive exists. |
| 2078 | /// A list says what order things come in; a track says a thing starts 135 |
| 2079 | /// minutes along and lasts 45, which is a different claim and not derivable |
| 2080 | /// from the first. |
| 2081 | |
| 2082 | |
| 2083 | at: u16, |
| 2084 | length: u16, |
| 2085 | |
| 2086 | |
| 2087 | |
| 2088 | /// A placement, clamped to a drawable one. |
| 2089 | /// |
| 2090 | /// Zero length becomes one for the same reason [`Span::new`] clamps: a |
| 2091 | /// zero-height thing is invisible rather than expressive, and every |
| 2092 | /// renderer would need its own guard. |
| 2093 | |
| 2094 | pub const |
| 2095 | Self |
| 2096 | at, |
| 2097 | length: if length == 0 else , |
| 2098 | |
| 2099 | |
| 2100 | |
| 2101 | /// Offset from the axis origin, matching [`Span`]'s. |
| 2102 | |
| 2103 | pub const |
| 2104 | self.at |
| 2105 | |
| 2106 | |
| 2107 | /// How long it lasts, in its track's unit. Never zero. |
| 2108 | |
| 2109 | pub const |
| 2110 | self.length |
| 2111 | |
| 2112 | |
| 2113 | /// One past its last minute. |
| 2114 | |
| 2115 | pub const |
| 2116 | self.at + self.length |
| 2117 | |
| 2118 | |
| 2119 | /// Whether two placements cover any of the same time. |
| 2120 | /// |
| 2121 | /// Geometry, and deliberately not a described field. Whether an overlap is |
| 2122 | /// a *conflict* is the app's judgment -- a meeting inside a block of free |
| 2123 | /// time overlaps and is fine -- and that judgment travels the way every |
| 2124 | /// other judgment does, as a [`Tone`] on the thing itself. What a renderer |
| 2125 | /// needs in order to lay two things side by side instead of on top of each |
| 2126 | /// other is this, and it can compute it. |
| 2127 | /// |
| 2128 | /// The alternative was a `conflicts: bool` on each entry, which is state |
| 2129 | /// that can disagree with the times beside it. Two sources for one fact is |
| 2130 | /// how a screen starts rendering a conflict badge on a thing that no longer |
| 2131 | /// conflicts. |
| 2132 | |
| 2133 | pub const |
| 2134 | self.at < other.end && other.at < self.end |
| 2135 | |
| 2136 | |
| 2137 | |
| 2138 | /// A time axis: things placed by when they happen, rather than flowed. |
| 2139 | /// |
| 2140 | /// # Why this is a primitive |
| 2141 | /// |
| 2142 | /// This crate refused to name it until 2026-08-15, on the argument that a |
| 2143 | /// description expressive enough to draw a timeline is a component library |
| 2144 | /// wearing a description's name. The refusal is withdrawn, and it is worth |
| 2145 | /// being precise about what was wrong with it, because the reasoning it used |
| 2146 | /// applies to real cases and should not be discarded with it. |
| 2147 | /// |
| 2148 | /// What a timeline needs that a [`List`](Region::Pane) does not is **one** |
| 2149 | /// thing: placement. Where a thing sits is a fact about the thing, the way a |
| 2150 | /// row's primary text is, and it is not derivable from order. Everything else a |
| 2151 | /// day view draws -- the labels, the gridlines, the item bodies, the tones -- |
| 2152 | /// is furniture this vocabulary already names. Measured against goingson's |
| 2153 | /// `day-planning-render.js`, the only members it needed and could not get were |
| 2154 | /// `at` and `minutes`. |
| 2155 | /// |
| 2156 | /// So the timeline was never a component library's worth of vocabulary. It was |
| 2157 | /// two integers, and the refusal was priced as though it were the whole widget. |
| 2158 | /// The test that matters is not "does this shape look complicated" but "how |
| 2159 | /// many members does it actually add, and are they facts or presentation". |
| 2160 | /// Slot heights, gridline colour, how overlaps stack and which hour scrolls |
| 2161 | /// into view on open are all presentation and all stay the renderer's, which is |
| 2162 | /// why they are absent here. |
| 2163 | /// |
| 2164 | /// # What it does not carry |
| 2165 | /// |
| 2166 | /// No pixel measure, no scroll offset, no drag affordance. A renderer draws the |
| 2167 | /// span at whatever density its host uses; `makeover-geometry` owns that the |
| 2168 | /// way it owns everything else measured in pixels. |
| 2169 | |
| 2170 | |
| 2171 | /// The window the axis covers. |
| 2172 | pub span: Span, |
| 2173 | /// The granularity a thing can be placed on, in minutes. |
| 2174 | /// |
| 2175 | /// goingson's day view is 15, giving 96 slots across a day. A renderer uses |
| 2176 | /// it to decide where gridlines fall and what a drop lands on; it does not |
| 2177 | /// constrain [`Placement`], because data arriving from a calendar does not |
| 2178 | /// respect anyone's grid. |
| 2179 | pub slot: u16, |
| 2180 | /// How often the axis labels itself, in its own unit. |
| 2181 | /// |
| 2182 | /// 60 gives an hourly ruler over a 15-minute grid, which is the common |
| 2183 | /// shape and the reason this is separate from `slot`. Zero means an |
| 2184 | /// unlabelled axis. |
| 2185 | pub tick: u16, |
| 2186 | /// What `span`, `slot`, `tick` and every [`Placement`] on it count. |
| 2187 | /// |
| 2188 | /// The one field here a renderer cannot derive, and the reason it exists: |
| 2189 | /// [`fraction`](Self::fraction) is unit-agnostic, so a day-granularity |
| 2190 | /// track produced correct geometry under an hours-and-minutes ruler until |
| 2191 | /// this was added. Geometry never needed it; a label always did. |
| 2192 | pub unit: Unit, |
| 2193 | |
| 2194 | |
| 2195 | |
| 2196 | /// An ordinary day: midnight to midnight, quarter-hour slots, hourly ticks. |
| 2197 | pub const DAY: Self = Self |
| 2198 | span: DAY, |
| 2199 | slot: 15, |
| 2200 | tick: 60, |
| 2201 | unit: Minutes, |
| 2202 | ; |
| 2203 | |
| 2204 | /// A track over `span`, with the day's usual granularity. |
| 2205 | |
| 2206 | pub const |
| 2207 | Self |
| 2208 | span, |
| 2209 | slot: 15, |
| 2210 | tick: 60, |
| 2211 | unit: Minutes, |
| 2212 | |
| 2213 | |
| 2214 | |
| 2215 | /// A strip of whole days: one slot a day, a label a week. |
| 2216 | /// |
| 2217 | /// The shape a stretch of leave or a sprint is drawn on. Not a calendar -- |
| 2218 | /// it does not wrap into weeks, and the crate header says why that |
| 2219 | /// distinction is the whole of what a month grid still has over this. |
| 2220 | |
| 2221 | pub const |
| 2222 | Self |
| 2223 | span, |
| 2224 | slot: 1, |
| 2225 | tick: 7, |
| 2226 | unit: Days, |
| 2227 | |
| 2228 | |
| 2229 | |
| 2230 | /// How many slots the axis holds. |
| 2231 | /// |
| 2232 | /// Rounded up, so a span that does not divide evenly by `slot` still has a |
| 2233 | /// slot covering its tail rather than dropping it. Never zero: `slot` of 0 |
| 2234 | /// reads as one slot spanning the whole axis rather than a division by |
| 2235 | /// zero, since a renderer asking this question has already committed to |
| 2236 | /// drawing something. |
| 2237 | |
| 2238 | pub const |
| 2239 | if self.slot == 0 |
| 2240 | 1 |
| 2241 | else |
| 2242 | self.span.length.div_ceil |
| 2243 | |
| 2244 | |
| 2245 | |
| 2246 | /// Where a placement sits on the axis, as a fraction from 0.0 to 1.0. |
| 2247 | /// |
| 2248 | /// The one calculation every renderer would otherwise write itself, and the |
| 2249 | /// place the three would drift apart. Clamped, so a placement outside the |
| 2250 | /// span draws at the edge rather than off it -- an event running past |
| 2251 | /// midnight is a real thing and truncating it is better than either |
| 2252 | /// panicking or drawing it somewhere impossible. |
| 2253 | |
| 2254 | |
| 2255 | let span = f32from; |
| 2256 | let offset = f32from; |
| 2257 | .clamp |
| 2258 | |
| 2259 | |
| 2260 | |
| 2261 | |
| 2262 | |
| 2263 | SelfDAY |
| 2264 | |
| 2265 | |
| 2266 | |
| 2267 | |
| 2268 | |
| 2269 | /// What the control says. |
| 2270 | pub label: &'a str, |
| 2271 | /// The key that reaches it where a host has keys. |
| 2272 | /// |
| 2273 | /// The one member written for a terminal before there was one. A webview |
| 2274 | /// hangs it off `accesskey` or ignores it; a terminal has nothing else to |
| 2275 | /// offer, so this is the whole of how a control is reached there. |
| 2276 | pub key: , |
| 2277 | /// What pressing it means. [`Tone::Danger`] is the destructive one. |
| 2278 | pub tone: Tone, |
| 2279 | /// Disabled, or nothing said. |
| 2280 | /// |
| 2281 | /// [`State::Disabled`] is what changes what a renderer may do: see |
| 2282 | /// [`State::suppresses_interaction`], which is what says a disabled control |
| 2283 | /// is drawn and not reachable. It has been the only member since 0.19.0, |
| 2284 | /// and a control's focus is not sayable here at all — see the crate header, |
| 2285 | /// "Reach, focus and the focus ring". |
| 2286 | pub state: , |
| 2287 | |
| 2288 | |
| 2289 | |
| 2290 | /// An ordinary control, reachable, with no key. |
| 2291 | |
| 2292 | pub const |
| 2293 | Self |
| 2294 | label, |
| 2295 | key: None, |
| 2296 | tone: Neutral, |
| 2297 | state: None, |
| 2298 | |
| 2299 | |
| 2300 | |
| 2301 | /// The key that reaches it. |
| 2302 | |
| 2303 | pub const |
| 2304 | self.key = Some; |
| 2305 | self |
| 2306 | |
| 2307 | |
| 2308 | /// What pressing it means. |
| 2309 | |
| 2310 | pub const |
| 2311 | self.tone = tone; |
| 2312 | self |
| 2313 | |
| 2314 | |
| 2315 | /// Focus, or disabled. |
| 2316 | |
| 2317 | pub const |
| 2318 | self.state = Some; |
| 2319 | self |
| 2320 | |
| 2321 | |
| 2322 | /// Whether the control is drawn and does not answer. |
| 2323 | |
| 2324 | |
| 2325 | self.state.is_some_and |
| 2326 | |
| 2327 | |
| 2328 | |
| 2329 | /// A named part of a screen. |
| 2330 | /// |
| 2331 | /// The thing `makeover-geometry` deliberately does not name: it names the space |
| 2332 | /// *between* things by relationship, and nothing named the things. Six named |
| 2333 | /// members, taken from what the two webview apps actually use, plus |
| 2334 | /// [`Region::Bespoke`] for the parts no description should reach. Both apps' |
| 2335 | /// `layout.css` currently names exactly two things, `.raised` and `.well`, so |
| 2336 | /// this layer is absent rather than divergent, which makes it the cheapest of |
| 2337 | /// the schemas to add and the easiest to over-build. |
| 2338 | /// |
| 2339 | /// `#[non_exhaustive]` arrives with [`Region::Widget`], the pairing [`RowPart`] |
| 2340 | /// made at 0.9.0 and [`Readiness`] at 0.12.0, and for the same reason: the |
| 2341 | /// member after this one should not be a lockstep event across three renderers. |
| 2342 | |
| 2343 | |
| 2344 | |
| 2345 | /// A full-width strip with a title slot and an actions cluster, either of |
| 2346 | /// which may be empty. goingson's `.page-header`, Balanced Breakfast's |
| 2347 | /// `.header` and `.detail-header` are all this, differing only in which |
| 2348 | /// slots they fill. |
| 2349 | Band, |
| 2350 | /// A persistent column beside the content, holding navigation. |
| 2351 | Sidebar, |
| 2352 | /// A region of content with its own scroll. |
| 2353 | Pane, |
| 2354 | /// Things that belong together, and nothing else. |
| 2355 | /// |
| 2356 | /// The block [`Heading::Section`] has been naming since 0.2.0 without the |
| 2357 | /// vocabulary being able to contain it. A section heading is a leaf sitting |
| 2358 | /// *beside* the things it names, so nothing said where a section started or |
| 2359 | /// ended and a renderer learned one had ended only because the next heading |
| 2360 | /// arrived. |
| 2361 | /// |
| 2362 | /// # The measurement |
| 2363 | /// |
| 2364 | /// 41 [`Heading::Section`] sites across the ten screens described through |
| 2365 | /// the router, not one of them contained. audiofiles' settings screen is the |
| 2366 | /// clearest: one pane holding a heading, a field, a heading, two toggles, a |
| 2367 | /// heading, a toggle and a heading, which is four sections and no |
| 2368 | /// containers. Under the hand-written CSS the ports are replacing the same |
| 2369 | /// block is spelled `.settings-section` in goingson, `.form-section` and |
| 2370 | /// `.content-section` in the MNW server, `.help-section` in Balanced |
| 2371 | /// Breakfast: three apps, four names, one shape. |
| 2372 | /// |
| 2373 | /// # Why the existing members were the wrong answer |
| 2374 | /// |
| 2375 | /// [`Pane`](Self::Pane) is what apps reached for, and it is 28 of the 45 |
| 2376 | /// regions in the described screens. It claims a scroll of its own and |
| 2377 | /// [`Depth::Well`], so four settings groups inside a pane are four wells |
| 2378 | /// inside a well and four scroll contexts. Neither claim is true of a group. |
| 2379 | /// |
| 2380 | /// [`Widget`](Self::Widget) is wrong from the other side. Its own docs say a |
| 2381 | /// widget is never how a primitive gets added by the back door, and a run of |
| 2382 | /// related controls under a heading is furniture any app would have, which |
| 2383 | /// is the generic-against-bespoke bar a primitive has to clear. |
| 2384 | /// |
| 2385 | /// # What it does not carry |
| 2386 | /// |
| 2387 | /// **A heading.** A group usually has one and it is an ordinary node in the |
| 2388 | /// body, the way it already was. A group of related toggles with no heading |
| 2389 | /// is a real thing and a mandatory slot would forbid it. |
| 2390 | /// |
| 2391 | /// **A depth.** [`Depth::Flat`], on [`Bespoke`](Self::Bespoke)'s reasoning: |
| 2392 | /// it inherits, and an app that wants its group in a well puts it in a |
| 2393 | /// [`Pane`](Self::Pane), which composes rather than adding a knob here. |
| 2394 | /// |
| 2395 | /// **A colour.** Distinguishing sibling groups by colour is the thing this |
| 2396 | /// member was asked for and it is deliberately not stated here. The |
| 2397 | /// description says these things belong together; which of the theme's |
| 2398 | /// categorical colours a renderer reaches for, and whether it reaches for |
| 2399 | /// one at all, is derived from sibling order at the renderer. A terminal |
| 2400 | /// that tints nothing and separates with a rule is honouring this. |
| 2401 | Group, |
| 2402 | /// Two panes side by side, where the left chooses what the right shows. |
| 2403 | Split, |
| 2404 | /// Peer regions across, all of them equals. |
| 2405 | /// |
| 2406 | /// A kanban board's columns, and the shape [`Split`](Self::Split) is not: |
| 2407 | /// a split's two panes stand in a master-detail relationship, where the |
| 2408 | /// left chooses what the right shows. These choose nothing about each |
| 2409 | /// other. Each is a whole region and the set is the arrangement. |
| 2410 | /// |
| 2411 | /// # What it does not carry |
| 2412 | /// |
| 2413 | /// **How many.** The children say, and a count here would be a second |
| 2414 | /// source for something the description already states by containing them. |
| 2415 | /// |
| 2416 | /// **How wide.** Peers are equal by definition, so there is no [`Share`] to |
| 2417 | /// state. A board whose columns wanted different widths would be a |
| 2418 | /// different member, and no app has one. |
| 2419 | /// |
| 2420 | /// **What happens when there is no room.** Scroll across, wrap, or collapse |
| 2421 | /// to one column at a time: all three are right on some host, none is |
| 2422 | /// derivable from the description, and every one of them is presentation. |
| 2423 | /// A terminal that stacks them vertically is honouring this, not degrading |
| 2424 | /// it. |
| 2425 | /// |
| 2426 | /// # Why it is not an `Arrangement` |
| 2427 | /// |
| 2428 | /// [`Arrangement`] is the page's shape, and a board is usually a region |
| 2429 | /// *inside* a page that also has a band over it. Naming it here composes; |
| 2430 | /// naming it there would make a screen either a board or a list-detail and |
| 2431 | /// never a band above a board. It also keeps [`Arrangement::share`] |
| 2432 | /// meaningful, which a peer arrangement has no answer for. |
| 2433 | Columns, |
| 2434 | /// A set of panes, one visible at a time, with a [`Selector::Tabs`] above. |
| 2435 | TabGroup, |
| 2436 | /// Content over a scrim, taking input until dismissed. |
| 2437 | Modal, |
| 2438 | /// A region this crate names the *place* of and nothing else. The app owns |
| 2439 | /// what goes in it. |
| 2440 | /// |
| 2441 | /// The escape hatch, and the thing that keeps the description honest about |
| 2442 | /// its own limits. A day-plan timeline, a kanban board, a calendar and the |
| 2443 | /// paint interaction over the timeline are not describable here and are not |
| 2444 | /// going to become describable: a description expressive enough to produce |
| 2445 | /// a timeline is a widget library wearing a description's name. |
| 2446 | /// |
| 2447 | /// But a screen containing one still has to be a screen. Without this |
| 2448 | /// member the description covers only the boring screens, and the four that |
| 2449 | /// make goingson worth using would need a second, undescribed path beside |
| 2450 | /// the router. Two paths is how the vocabulary starts drifting from the app |
| 2451 | /// again, which is the exact failure this crate exists to end. |
| 2452 | /// |
| 2453 | /// So the description says "a thing called `day-plan` goes here" and stops. |
| 2454 | /// The name is opaque: this crate never interprets it, and no renderer is |
| 2455 | /// expected to know what it means beyond handing the space over. |
| 2456 | Bespoke |
| 2457 | /// What the app calls it. Never interpreted here. |
| 2458 | name: &'a str, |
| 2459 | , |
| 2460 | /// A named assembly of things the vocabulary already says. |
| 2461 | /// |
| 2462 | /// The third tier, between a primitive and [`Bespoke`](Self::Bespoke). |
| 2463 | /// Stated by Max 2026-08-12 answering the carousel: "something in between a |
| 2464 | /// primitive and a bespoke interface, like a widget, which is just an |
| 2465 | /// assembly of primitives." Full note: wiki `widget-tier`. |
| 2466 | /// |
| 2467 | /// # What separates it from the two members either side |
| 2468 | /// |
| 2469 | /// A primitive is a thing every renderer draws from scratch, and the test |
| 2470 | /// it has to pass is that every host has an honest answer. A carousel fails |
| 2471 | /// that test — a terminal has no carousel — which is the same refusal |
| 2472 | /// `Node::Html` got and is why the carousel sat unsayable for months. |
| 2473 | /// |
| 2474 | /// [`Bespoke`](Self::Bespoke) fails it from the other side. Bespoke is for |
| 2475 | /// what one app owns and nobody will build twice, and it carries *no* |
| 2476 | /// contents: the description names the place and stops. A carousel is |
| 2477 | /// furniture any app would have, and every part of it — an ordered set of |
| 2478 | /// frames, a position, prev and next, a strip of position indicators — is |
| 2479 | /// already sayable. Only the assembly had no name. |
| 2480 | /// |
| 2481 | /// So this member is the pair the other two are not: a name **and** |
| 2482 | /// contents. The contents are the assembly, in the region's own body, said |
| 2483 | /// in members that already exist. |
| 2484 | /// |
| 2485 | /// # Why the name does not have to be understood |
| 2486 | /// |
| 2487 | /// A renderer that recognises the name draws it the way its host does it: a |
| 2488 | /// carousel in a webview, a pager with a count in a terminal, a selector in |
| 2489 | /// egui. A renderer that does not recognise it walks the body, which is |
| 2490 | /// primitives all the way down and which it can already draw. |
| 2491 | /// |
| 2492 | /// That is what lets the widget set be **open** without every renderer |
| 2493 | /// knowing every widget. An unrecognised widget degrades to its assembly |
| 2494 | /// instead of failing, so a second or third party can name one without |
| 2495 | /// three renderers releasing in lockstep to accept it. Contrast |
| 2496 | /// [`Bespoke`](Self::Bespoke), which no renderer can degrade: there is |
| 2497 | /// nothing under it to fall back to. |
| 2498 | /// |
| 2499 | /// # What it does not do |
| 2500 | /// |
| 2501 | /// A widget is an assembly of things the vocabulary *already* says, so it |
| 2502 | /// buys no expressive power. Anything needing a member the vocabulary does |
| 2503 | /// not have is a finding about the vocabulary, and the answer to a finding |
| 2504 | /// is to add the member. A widget is never the way a primitive gets added |
| 2505 | /// by the back door. |
| 2506 | /// |
| 2507 | /// This used to say "it does not make a timeline describable, and the |
| 2508 | /// refusal in the crate header stands unchanged". The timeline is |
| 2509 | /// describable as of 2026-08-15 -- see [`Track`] -- and it got there the |
| 2510 | /// way the paragraph above says it should have: by adding the two members |
| 2511 | /// that were missing, not by dressing the screen up as an assembly. |
| 2512 | Widget |
| 2513 | /// What the assembly is called. This crate never interprets it, and a |
| 2514 | /// renderer is free not to know it. |
| 2515 | name: &'a str, |
| 2516 | , |
| 2517 | |
| 2518 | |
| 2519 | |
| 2520 | /// How the region sits on what is behind it. |
| 2521 | |
| 2522 | pub const |
| 2523 | match self |
| 2524 | SelfBand | SelfSidebar | SelfSplit | SelfTabGroup => Flat, |
| 2525 | // Flat, and it inherits. A group says its contents belong together |
| 2526 | // and says nothing about the surface they sit on, so a group in a |
| 2527 | // pane is in a well and a group on the page is on the page. An app |
| 2528 | // wanting one lifted puts it in a `Pane`. |
| 2529 | SelfGroup => Flat, |
| 2530 | // Flat, and it is the container rather than the columns. Each |
| 2531 | // column is its own region and brings its own depth; a well here |
| 2532 | // would put a second edge around a row of wells. |
| 2533 | SelfColumns => Flat, |
| 2534 | // A pane is looked into, the same as a table body or a tag tree. |
| 2535 | SelfPane => Well, |
| 2536 | SelfModal => Raised, |
| 2537 | // Flat because it inherits: a bespoke region takes the depth of |
| 2538 | // whatever frames it. An app that wants its timeline in a well puts |
| 2539 | // it in a `Pane`, which composes rather than adding a knob here. |
| 2540 | // |
| 2541 | // A widget inherits for the same reason and it matters more here, |
| 2542 | // because a widget is drawn by whichever renderer recognises it. A |
| 2543 | // depth set here would be this crate deciding that a carousel is |
| 2544 | // raised on every host, which is the kind of value the deferral |
| 2545 | // rule exists to refuse. |
| 2546 | SelfBespoke | SelfWidget => Flat, |
| 2547 | |
| 2548 | |
| 2549 | |
| 2550 | /// Whether this crate can say anything about the region's contents. |
| 2551 | /// |
| 2552 | /// A renderer walks the description and hands every region it understands |
| 2553 | /// to the right drawing code. This is how it tells the two apart, and the |
| 2554 | /// reason it is a method rather than a `matches!` at each renderer: there |
| 2555 | /// is exactly one opaque member and there should stay exactly one. |
| 2556 | /// |
| 2557 | /// [`Widget`](Self::Widget) is described, and that is the whole of what |
| 2558 | /// separates it from [`Bespoke`](Self::Bespoke) here. Both carry a name |
| 2559 | /// this crate never interprets; only one of them carries contents under it. |
| 2560 | /// A renderer that does not recognise a widget's name still walks its body, |
| 2561 | /// so there is nothing for it to hand over and nothing it cannot draw. |
| 2562 | |
| 2563 | pub const |
| 2564 | !matches! |
| 2565 | |
| 2566 | |
| 2567 | /// The name an app gave this region, if it gave one. |
| 2568 | /// |
| 2569 | /// [`Bespoke`](Self::Bespoke) and [`Widget`](Self::Widget) are the two |
| 2570 | /// members that carry a name, for two different purposes: one says what the |
| 2571 | /// app will fill the space with, the other says what the assembly under it |
| 2572 | /// is called. A renderer dispatching on either wants the string without |
| 2573 | /// caring which member it came from, and writing that `matches!` at each |
| 2574 | /// renderer is how the two drift apart. |
| 2575 | |
| 2576 | pub const |
| 2577 | match self |
| 2578 | SelfBespoke | SelfWidget => Some, |
| 2579 | // Spelled out rather than a wildcard, so a member added later has |
| 2580 | // to answer whether it carries a name instead of inheriting `None` |
| 2581 | // by sitting under a `_`. |
| 2582 | SelfBand |
| 2583 | | SelfSidebar |
| 2584 | | SelfPane |
| 2585 | | SelfGroup |
| 2586 | | SelfSplit |
| 2587 | | SelfColumns |
| 2588 | | SelfTabGroup |
| 2589 | | SelfModal => None, |
| 2590 | |
| 2591 | |
| 2592 | |
| 2593 | |
| 2594 | /// How many of a region's children are visible at once. |
| 2595 | /// |
| 2596 | /// `4dcd241b`. Three findings turned out to be one sentence the vocabulary |
| 2597 | /// could not say: *this region holds several children and shows some of them, |
| 2598 | /// and the reader can change which.* [`Region::TabGroup`] existed with nothing |
| 2599 | /// saying which tab was open, a carousel had nothing saying which frame was up, |
| 2600 | /// and a disclosure had nothing saying whether its one child was showing at all. |
| 2601 | /// |
| 2602 | /// Because the fact lived nowhere, a renderer had two moves: hardcode a widget |
| 2603 | /// name, or draw every child. That is what put per-widget code in renderers, and |
| 2604 | /// it was the missing member rather than the widget tier that put it there. |
| 2605 | /// |
| 2606 | /// # What is here and what is not |
| 2607 | /// |
| 2608 | /// The *kind*, and only the kind. Which child is currently up is the current |
| 2609 | /// answer, and a layer that defers every address does not hold the current |
| 2610 | /// answer either — the split [`Selector`] already makes, where this crate says |
| 2611 | /// what kind of chooser a thing is and the router says which option is picked. |
| 2612 | /// So a holder of regions carries the index and the per-child label beside this. |
| 2613 | /// |
| 2614 | /// # What a renderer does with it |
| 2615 | /// |
| 2616 | /// Derives its chrome, once, for every widget rather than per name: |
| 2617 | /// |
| 2618 | /// - Children carrying labels get a strip of the labels, the current one marked. |
| 2619 | /// - Children carrying none get previous, position, next. |
| 2620 | /// - [`AtMostOne`](Self::AtMostOne) over one child gets a summary line that |
| 2621 | /// opens. |
| 2622 | /// |
| 2623 | /// The name on [`Region::Widget`] survives as app vocabulary, for a renderer |
| 2624 | /// that wants to do something *special* with one, which is what it should have |
| 2625 | /// been from the start. |
| 2626 | /// |
| 2627 | /// Degradation runs the way it already did: a renderer ignoring this draws every |
| 2628 | /// child, which is more content rather than less. |
| 2629 | |
| 2630 | |
| 2631 | |
| 2632 | /// Every child, in order. What every region did before this existed. |
| 2633 | |
| 2634 | All, |
| 2635 | /// Exactly one. A carousel, a tab group. |
| 2636 | One, |
| 2637 | /// One, or none. A disclosure, which is closed until it is opened. |
| 2638 | AtMostOne, |
| 2639 | |
| 2640 | |
| 2641 | |
| 2642 | /// Whether the reader can change which child is up. |
| 2643 | /// |
| 2644 | /// The question every renderer's region arm asks before deriving any |
| 2645 | /// chrome, and a method rather than a `matches!` at each renderer for |
| 2646 | /// [`Region::name`]'s reason: three renderers writing the same comparison is |
| 2647 | /// how they come to disagree about a member added later. |
| 2648 | |
| 2649 | pub const |
| 2650 | !matches! |
| 2651 | |
| 2652 | |
| 2653 | /// Whether showing nothing is a legal state. |
| 2654 | /// |
| 2655 | /// True only for [`AtMostOne`](Self::AtMostOne). A renderer needs this to |
| 2656 | /// know whether its control closes as well as moves: a carousel's row moves |
| 2657 | /// between frames and never reaches empty, and a disclosure's summary line |
| 2658 | /// is the same control wearing its closed state. |
| 2659 | |
| 2660 | pub const |
| 2661 | matches! |
| 2662 | |
| 2663 | |
| 2664 | |
| 2665 | /// A window onto a sequence: where it starts, how much it covers, and how long |
| 2666 | /// the sequence is when that is known. |
| 2667 | /// |
| 2668 | /// The mechanism under two things the vocabulary deliberately keeps apart. A |
| 2669 | /// carousel is a window of one frame over children that are all present; a |
| 2670 | /// paged list is a window of a page over rows most of which were never fetched. |
| 2671 | /// Those are different facts and they stay different types — [`Showing`] says |
| 2672 | /// which child is up, [`Paging`] says where a reader is in a query — but the |
| 2673 | /// arithmetic underneath is one piece of code, so a terminal and a browser |
| 2674 | /// cannot come to disagree about which frame is last. |
| 2675 | /// |
| 2676 | /// # Why `of` is optional and `count` is not |
| 2677 | /// |
| 2678 | /// `count` is what is on screen and is therefore always known. `of` is the |
| 2679 | /// length of the thing being windowed, and a host that cannot count says so by |
| 2680 | /// leaving it empty **for the life of the screen**. It is never "not counted |
| 2681 | /// yet": see "First paint is final paint" in the crate header. A total that |
| 2682 | /// turns up on a later pass widens the text that prints it. |
| 2683 | /// |
| 2684 | /// # Clamping |
| 2685 | /// |
| 2686 | /// Every derivation clamps rather than refusing, and a zero `count` answers |
| 2687 | /// `None` rather than dividing. A window past the end is a bug in the host, and |
| 2688 | /// a renderer that answered it by drawing nothing would report a region that |
| 2689 | /// vanished, which is the hardest kind of bug to find from what is on screen. |
| 2690 | /// [`Share::percent`] clamps for the same reason. |
| 2691 | |
| 2692 | |
| 2693 | /// The index into the sequence where the window starts. |
| 2694 | pub from: usize, |
| 2695 | /// How many the window covers. One, for a carousel. |
| 2696 | pub count: usize, |
| 2697 | /// How long the sequence is, when the host can say. |
| 2698 | pub of: , |
| 2699 | |
| 2700 | |
| 2701 | |
| 2702 | /// A window of `count`, starting at `from`, over a sequence of unknown |
| 2703 | /// length. |
| 2704 | |
| 2705 | pub const |
| 2706 | Self |
| 2707 | from, |
| 2708 | count, |
| 2709 | of: None, |
| 2710 | |
| 2711 | |
| 2712 | |
| 2713 | /// How long the sequence is. |
| 2714 | |
| 2715 | pub const |
| 2716 | self.of = Some; |
| 2717 | self |
| 2718 | |
| 2719 | |
| 2720 | /// One item of a sequence whose length is known. A carousel frame. |
| 2721 | |
| 2722 | pub const |
| 2723 | Self |
| 2724 | from: at, |
| 2725 | count: 1, |
| 2726 | of: Some, |
| 2727 | |
| 2728 | |
| 2729 | |
| 2730 | /// Which window this is, counting from zero. |
| 2731 | /// |
| 2732 | /// `None` when `count` is zero, which is the only input with no answer |
| 2733 | /// rather than a clamped one. |
| 2734 | |
| 2735 | pub const |
| 2736 | if self.count == 0 |
| 2737 | return None; |
| 2738 | |
| 2739 | Some |
| 2740 | |
| 2741 | |
| 2742 | /// How many windows the sequence holds. |
| 2743 | /// |
| 2744 | /// `None` unless both the length and a non-zero `count` are known. A |
| 2745 | /// partial answer here would be a renderer drawing "of 0". |
| 2746 | |
| 2747 | pub const |
| 2748 | match self.of |
| 2749 | Some if self.count > 0 => Some, |
| 2750 | _ => None, |
| 2751 | |
| 2752 | |
| 2753 | |
| 2754 | /// Whether anything sits before this window. |
| 2755 | |
| 2756 | pub const |
| 2757 | self.from > 0 |
| 2758 | |
| 2759 | |
| 2760 | /// How many sit after this window, when the length is known. |
| 2761 | /// |
| 2762 | /// Here rather than in each renderer for [`Showing::selective`]'s reason: |
| 2763 | /// three of them writing the same subtraction is how they come to disagree, |
| 2764 | /// and this one has an underflow in it for whoever writes it fourth. |
| 2765 | |
| 2766 | pub const |
| 2767 | match self.of |
| 2768 | Some => Some, |
| 2769 | None => None, |
| 2770 | |
| 2771 | |
| 2772 | |
| 2773 | /// Whether anything sits after it. |
| 2774 | /// |
| 2775 | /// `true` when the length is unknown: a host that cannot count cannot rule |
| 2776 | /// out more, and offering a way forward that turns out to be empty is the |
| 2777 | /// cheaper of the two mistakes. |
| 2778 | |
| 2779 | pub const |
| 2780 | match self.of |
| 2781 | Some => self.from.saturating_add < of, |
| 2782 | None => true, |
| 2783 | |
| 2784 | |
| 2785 | |
| 2786 | /// The window with `from` brought inside the sequence. |
| 2787 | /// |
| 2788 | /// A no-op when the length is unknown, since there is nothing to clamp |
| 2789 | /// against. |
| 2790 | |
| 2791 | pub const |
| 2792 | if let Some = self.of |
| 2793 | && self.from >= of |
| 2794 | |
| 2795 | // `max(1)` by hand: `Ord::max` is not const yet, and a zero-count |
| 2796 | // window would otherwise clamp onto the end rather than inside it. |
| 2797 | let step = if self.count == 0 else ; |
| 2798 | self.from = of.saturating_sub; |
| 2799 | |
| 2800 | self |
| 2801 | |
| 2802 | |
| 2803 | |
| 2804 | /// Where a reader is in a set that arrived in parts. |
| 2805 | /// |
| 2806 | /// A [`Window`] wearing the paged reading of itself. Distinct from a carousel's |
| 2807 | /// window at the top level on purpose, because the intent differs and a call |
| 2808 | /// site should say which one it means, while the arithmetic below is shared so |
| 2809 | /// the two cannot drift apart. |
| 2810 | /// |
| 2811 | /// # The two idioms, and which one a renderer may draw |
| 2812 | /// |
| 2813 | /// Load-more and numbered pages are both this type. Which is honest is |
| 2814 | /// [`paged`](Self::paged): a set whose page size is known can be drawn as |
| 2815 | /// "Page 3 of 8", and one without can only be drawn as "150 of 400" and a way |
| 2816 | /// forward. Saying it here rather than letting each renderer guess is the point |
| 2817 | /// — three renderers inferring it from the numbers is how they come to disagree. |
| 2818 | /// |
| 2819 | /// # What it does not carry |
| 2820 | /// |
| 2821 | /// No addresses. `makeover-layout` cannot name an action, and the way to ask for |
| 2822 | /// the next part is the host's: `quasi_router` pairs this with the addresses the |
| 2823 | /// same way `Row` pairs its parts with `Row::activate`. That split is the reason |
| 2824 | /// this type is reusable by a carousel, which has nothing to ask. |
| 2825 | |
| 2826 | |
| 2827 | /// The window onto the set. |
| 2828 | pub window: Window, |
| 2829 | /// Whether the parts are a fixed size, and so whether pages are countable. |
| 2830 | /// |
| 2831 | /// `false` for load-more, where the window simply grew and "page 2" would |
| 2832 | /// name nothing. |
| 2833 | pub paged: bool, |
| 2834 | |
| 2835 | |
| 2836 | |
| 2837 | /// A page of `per`, starting at `from`. |
| 2838 | |
| 2839 | pub const |
| 2840 | Self |
| 2841 | window: new, |
| 2842 | paged: true, |
| 2843 | |
| 2844 | |
| 2845 | |
| 2846 | /// The first `shown`, with more behind them. |
| 2847 | /// |
| 2848 | /// The load-more shape: the window starts at the beginning and grows, so |
| 2849 | /// there is no page to number. |
| 2850 | |
| 2851 | pub const |
| 2852 | Self |
| 2853 | window: new, |
| 2854 | paged: false, |
| 2855 | |
| 2856 | |
| 2857 | |
| 2858 | /// How many there are altogether. |
| 2859 | /// |
| 2860 | /// Left unsaid by a host that cannot count, and left unsaid **for good**: |
| 2861 | /// a total arriving later widens whatever prints it. See "First paint is |
| 2862 | /// final paint" in the crate header. |
| 2863 | |
| 2864 | pub const |
| 2865 | self.window = self.window.of; |
| 2866 | self |
| 2867 | |
| 2868 | |
| 2869 | /// Which page this is, counting from one, when pages are countable. |
| 2870 | /// |
| 2871 | /// One-based because it is read aloud. [`Window::index`] is the zero-based |
| 2872 | /// form for anyone indexing with it. |
| 2873 | |
| 2874 | pub const |
| 2875 | if !self.paged |
| 2876 | return None; |
| 2877 | |
| 2878 | match self.window.index |
| 2879 | Some => Some, |
| 2880 | None => None, |
| 2881 | |
| 2882 | |
| 2883 | |
| 2884 | /// How many pages there are, when that is countable. |
| 2885 | |
| 2886 | pub const |
| 2887 | if !self.paged |
| 2888 | return None; |
| 2889 | |
| 2890 | self.window.windows |
| 2891 | |
| 2892 | |
| 2893 | /// How many are on screen. |
| 2894 | |
| 2895 | pub const |
| 2896 | self.window.count |
| 2897 | |
| 2898 | |
| 2899 | /// How many there are, when the host counted. |
| 2900 | |
| 2901 | pub const |
| 2902 | self.window.of |
| 2903 | |
| 2904 | |
| 2905 | /// How many are not shown yet, when the host counted. |
| 2906 | /// |
| 2907 | /// The figure a load-more control puts in its label. `None` is the honest |
| 2908 | /// and common case: a set that cannot say how many more there are still has |
| 2909 | /// a way to ask for them. |
| 2910 | |
| 2911 | pub const |
| 2912 | self.window.after |
| 2913 | |
| 2914 | |
| 2915 | /// Whether there is anything further on. |
| 2916 | |
| 2917 | pub const |
| 2918 | self.window.has_after |
| 2919 | |
| 2920 | |
| 2921 | /// Whether there is anything back the other way. |
| 2922 | |
| 2923 | pub const |
| 2924 | self.window.has_before |
| 2925 | |
| 2926 | |
| 2927 | |
| 2928 | /// How much of the width an arrangement's first region takes. |
| 2929 | /// |
| 2930 | /// `e0fd485e`. Nothing said how much room a region got, so every renderer |
| 2931 | /// invented its own number and two hosts showing one screen disagreed about |
| 2932 | /// its proportions. A webview never noticed, because the stylesheet answered |
| 2933 | /// once for every consumer; a terminal has no stylesheet to inherit from, so |
| 2934 | /// `quasi-tui` picked 24 columns for a sidebar and 40% for a list pane and |
| 2935 | /// neither had anything behind it. |
| 2936 | /// |
| 2937 | /// # A proportion, never a unit |
| 2938 | /// |
| 2939 | /// Held as a percentage, and that is the only form it comes in. A description |
| 2940 | /// carrying columns would be describing a terminal and one carrying pixels a |
| 2941 | /// webview, and the whole point is that both honour the same fact: a terminal |
| 2942 | /// resolves it against a column count, a webview writes it into a grid, and |
| 2943 | /// neither has to know what the other did. |
| 2944 | /// |
| 2945 | /// It is not [`makeover_geometry::Ratio`]'s job either, which was the first |
| 2946 | /// guess. Geometry is scales that answer the same for every screen and takes |
| 2947 | /// no input that would let a sidebar screen differ from a list-detail one. |
| 2948 | /// |
| 2949 | /// [`makeover_geometry::Ratio`]: https://docs.rs/makeover-geometry |
| 2950 | |
| 2951 | ; |
| 2952 | |
| 2953 | |
| 2954 | /// What a sidebar takes, when nobody says otherwise. |
| 2955 | /// |
| 2956 | /// A quarter. `quasi-tui` drew 24 columns, which is a quarter of a |
| 2957 | /// 96-column terminal and about a fifth of a wide one; a quarter is that |
| 2958 | /// number said in the form a webview can honour too. |
| 2959 | pub const SIDEBAR: Self = Self; |
| 2960 | |
| 2961 | /// What the list side of a list-detail takes, when nobody says otherwise. |
| 2962 | /// |
| 2963 | /// `quasi-tui`'s 40%, which was already a proportion and is the one number |
| 2964 | /// this member did not have to invent. |
| 2965 | pub const LIST: Self = Self; |
| 2966 | |
| 2967 | /// A share of the width, as a percentage. |
| 2968 | /// |
| 2969 | /// Clamped to 5..=95 rather than refused. A description that asked for a |
| 2970 | /// region of nothing is a bug in the app, and a renderer drawing a region |
| 2971 | /// zero cells wide reports it as a region that vanished, which is the |
| 2972 | /// hardest kind of bug to find from what is on the screen. |
| 2973 | |
| 2974 | pub const |
| 2975 | Self |
| 2976 | 5 |
| 2977 | else if percent > 95 |
| 2978 | 95 |
| 2979 | else |
| 2980 | percent |
| 2981 | |
| 2982 | |
| 2983 | |
| 2984 | /// The share as a percentage. |
| 2985 | |
| 2986 | pub const |
| 2987 | self.0 |
| 2988 | |
| 2989 | |
| 2990 | /// This share of a width, rounded to the nearest whole unit. |
| 2991 | /// |
| 2992 | /// What a terminal calls to turn the proportion into columns. At least one, |
| 2993 | /// because a region the description named should be visible: a screen |
| 2994 | /// 3 columns wide is unusable either way, and a sidebar that is there is a |
| 2995 | /// truer picture of the description than a sidebar that is not. |
| 2996 | |
| 2997 | pub const |
| 2998 | let taken = .div_ceil; |
| 2999 | if taken == 0 else |
| 3000 | |
| 3001 | |
| 3002 | |
| 3003 | /// How a screen is laid out. |
| 3004 | /// |
| 3005 | /// Two, and the second is not a variant of the first. goingson is list-detail, |
| 3006 | /// Balanced Breakfast is sidebar plus content, and neither app has a third. |
| 3007 | /// The tab group is a modifier rather than a member, because goingson uses it |
| 3008 | /// *inside* the same content region rather than instead of one. |
| 3009 | /// |
| 3010 | /// This exists at all because the router has to be able to express a screen |
| 3011 | /// rather than only a control. Discovering the arrangement layer missing after |
| 3012 | /// the renderers exist is a redesign; naming two now is a morning. |
| 3013 | /// |
| 3014 | /// # Why the share rides here |
| 3015 | /// |
| 3016 | /// `e0fd485e`. A share is per-arrangement: how much a sidebar takes and how |
| 3017 | /// much a list side takes are different questions, and this enum is the only |
| 3018 | /// thing that knows which one is being asked. Geometry would have had to invent |
| 3019 | /// a channel to be told. |
| 3020 | /// |
| 3021 | /// [`list_detail`](Self::list_detail) and |
| 3022 | /// [`sidebar_content`](Self::sidebar_content) build these with the default |
| 3023 | /// shares, so a screen that has no opinion does not have to have one. |
| 3024 | |
| 3025 | |
| 3026 | /// A list that chooses what the detail beside it shows. |
| 3027 | ListDetail |
| 3028 | /// Whether the detail side is a [`Region::TabGroup`]. |
| 3029 | tabbed: bool, |
| 3030 | /// How much of the width the list side takes. |
| 3031 | share: Share, |
| 3032 | , |
| 3033 | /// Navigation down the side, content filling the rest. |
| 3034 | SidebarContent |
| 3035 | /// How much of the width the sidebar takes. |
| 3036 | share: Share, |
| 3037 | , |
| 3038 | |
| 3039 | |
| 3040 | |
| 3041 | /// A list and a detail beside it, at the default share. |
| 3042 | |
| 3043 | pub const |
| 3044 | SelfListDetail |
| 3045 | tabbed, |
| 3046 | share: LIST, |
| 3047 | |
| 3048 | |
| 3049 | |
| 3050 | /// A sidebar and content beside it, at the default share. |
| 3051 | |
| 3052 | pub const |
| 3053 | SelfSidebarContent |
| 3054 | share: SIDEBAR, |
| 3055 | |
| 3056 | |
| 3057 | |
| 3058 | /// How much of the width the first region takes. |
| 3059 | |
| 3060 | pub const |
| 3061 | match self |
| 3062 | SelfListDetail | SelfSidebarContent => share, |
| 3063 | |
| 3064 | |
| 3065 | |
| 3066 | /// The same arrangement, at this share. |
| 3067 | |
| 3068 | pub const |
| 3069 | match self |
| 3070 | SelfListDetail => SelfListDetail , |
| 3071 | SelfSidebarContent => SelfSidebarContent , |
| 3072 | |
| 3073 | |
| 3074 | |
| 3075 | |
| 3076 | /// How wide the content of a whole screen runs. |
| 3077 | /// |
| 3078 | /// `0eccff0d`, and [`Share`]'s sibling one level up: that one says how a |
| 3079 | /// screen's width is divided between regions, this says how much of the window |
| 3080 | /// the screen uses in the first place. Both are the description's, which is |
| 3081 | /// what answering the two together settled. |
| 3082 | /// |
| 3083 | /// Measured in the MNW server, where 69 of 72 templates carry exactly one of |
| 3084 | /// three mutually exclusive classes and the choice is per screen. GoingsOn |
| 3085 | /// reaches for `max-width` 56 times and Balanced Breakfast 12, neither with a |
| 3086 | /// token for it, so three apps were solving one thing by hand. |
| 3087 | /// |
| 3088 | /// # Named for the measure, not for MNW's classes |
| 3089 | /// |
| 3090 | /// A renderer that is not a browser has to answer this too, and `padded-page` |
| 3091 | /// tells a terminal nothing. The three say how wide the text runs, which is a |
| 3092 | /// question every renderer can answer: a webview with a `max-width`, a terminal |
| 3093 | /// with gutters, an immediate-mode frame with its own width. |
| 3094 | /// |
| 3095 | /// `#[non_exhaustive]` for [`Fill`]'s reason. The set is closed today because |
| 3096 | /// the measurement found three, and a fourth arriving should not be a lockstep |
| 3097 | /// release across nine repos. |
| 3098 | |
| 3099 | |
| 3100 | |
| 3101 | /// The whole width, with gutters. The default, and 53 of the 69. |
| 3102 | /// |
| 3103 | /// What a dashboard, a table and a settings screen want: the content is |
| 3104 | /// wide because the content *is* wide, and constraining it would waste the |
| 3105 | /// window. |
| 3106 | |
| 3107 | Wide, |
| 3108 | /// Capped at a comfortable page width, centred. 13 of the 69. |
| 3109 | /// |
| 3110 | /// A form, a sign-in, a purchase. Content that does not get better by |
| 3111 | /// getting wider, but is not prose either. |
| 3112 | Contained, |
| 3113 | /// Capped at a line length that reads well. 3 of the 69. |
| 3114 | /// |
| 3115 | /// Prose. The narrowest of the three, and the one with a reason outside |
| 3116 | /// taste: a line of text past roughly 75 characters costs the reader the |
| 3117 | /// return sweep. |
| 3118 | Reading, |
| 3119 | |
| 3120 | |
| 3121 | |
| 3122 | /// A stable name, for a renderer that needs to spell it. |
| 3123 | /// |
| 3124 | /// Here rather than in each renderer for [`Sort::as_str`]'s reason: three |
| 3125 | /// renderers spelling one enum is three chances to spell it differently. |
| 3126 | |
| 3127 | pub const |
| 3128 | match self |
| 3129 | SelfWide => "wide", |
| 3130 | SelfContained => "contained", |
| 3131 | SelfReading => "reading", |
| 3132 | |
| 3133 | |
| 3134 | |
| 3135 | |
| 3136 | /// What kind of value a form field takes. |
| 3137 | /// |
| 3138 | /// The union of the two vocabularies that diverged, which is what triggered |
| 3139 | /// this crate. They have since converged on their own: both apps now have a |
| 3140 | /// `renderFormField` emitting the same anatomy, and what is left differing is |
| 3141 | /// the kind set, the error shape, and whether the return is a string or a node. |
| 3142 | /// |
| 3143 | /// Validation is deliberately absent. Neither app has a shared story (goingson |
| 3144 | /// validates after collecting the form data, with per-field transform hooks; |
| 3145 | /// Balanced Breakfast has `required` and nothing else), and a schema that |
| 3146 | /// describes fields but not constraints acquires a constraint layer per app, |
| 3147 | /// which is exactly how the current divergence started. Naming it absent is a |
| 3148 | /// decision; leaving it unmentioned would not be. |
| 3149 | /// `#[non_exhaustive]` for the reason [`Fill`] is: renderers match on this and |
| 3150 | /// the set keeps growing, so growth must not be a lockstep event. Email, Url |
| 3151 | /// and Tel arriving in 0.5.0 is the second growth in two releases. |
| 3152 | |
| 3153 | |
| 3154 | |
| 3155 | /// A single line of text. |
| 3156 | Text, |
| 3157 | /// A single line of text that must never be echoed, logged or round-tripped |
| 3158 | /// through anything that might persist it. |
| 3159 | Secret, |
| 3160 | /// A number. |
| 3161 | Number, |
| 3162 | /// A number inside bounds the user drags across, where the range being |
| 3163 | /// visible is the point. |
| 3164 | /// |
| 3165 | /// Not [`Number`](Self::Number) with [`min`](Field::min) and |
| 3166 | /// [`max`](Field::max), which is the reading to resist and is the same |
| 3167 | /// resistance [`Radio`](Self::Radio) needed against `Select`. A bounded |
| 3168 | /// number and a validated number are different *questions*. A validated |
| 3169 | /// number is typed and can be wrong: the bounds are a rule the answer is |
| 3170 | /// checked against, and being told "must be at least 1" afterwards is the |
| 3171 | /// normal course of it. A range cannot be out of range at all, because the |
| 3172 | /// bounds are the control's extent rather than a rule, and the two ends are |
| 3173 | /// what the question means — audiofiles asks for a classifier threshold |
| 3174 | /// between 0 and 1, where 0 is never and 1 is only-on-certainty, and a typed |
| 3175 | /// 0.72 says nothing without both ends on screen beside it. |
| 3176 | /// |
| 3177 | /// A renderer cannot infer which one is meant from `min`/`max` alone, which |
| 3178 | /// is why this is a kind and not an inference: goingson's `min="1"` duration |
| 3179 | /// is a validated number and would become a slider. |
| 3180 | /// |
| 3181 | /// The membership test passes without stretching: a webview emits |
| 3182 | /// `<input type="range">`, egui has `Slider`, a terminal draws a bar and |
| 3183 | /// takes arrow keys, a CLI takes a bounded argument. |
| 3184 | /// |
| 3185 | /// # It owes its bounds |
| 3186 | /// |
| 3187 | /// [`min`](Field::min) and [`max`](Field::max) are `Option` for every other |
| 3188 | /// kind and are **required** here, in the sense the description can require |
| 3189 | /// anything: [`Field::bounded`] is the check, and a range missing one has no |
| 3190 | /// extent for a renderer to draw. What a renderer does with an unbounded |
| 3191 | /// range is its own call and both answers are honest — fall back to a typed |
| 3192 | /// number, or pick a host default — so this is stated rather than enforced, |
| 3193 | /// the way every other constraint here is. |
| 3194 | /// |
| 3195 | /// [`Field::step`] is the third fact and is genuinely optional: absent, the |
| 3196 | /// host's own granularity stands. |
| 3197 | /// |
| 3198 | /// Added 0.28.0, from audiofiles' classifier thresholds and storage cap |
| 3199 | /// picker (`fb93426b`), where four sliders were hand-rolled against a |
| 3200 | /// vocabulary that could not say what they were. |
| 3201 | Range, |
| 3202 | /// An email address. |
| 3203 | /// |
| 3204 | /// Distinct from [`Text`](Self::Text) because the distinction is not |
| 3205 | /// decoration: a webview renderer emits `type="email"`, which on a touch |
| 3206 | /// device changes the keyboard that appears and turns on the platform's own |
| 3207 | /// validation. goingson ships to iOS, so collapsing this into text costs a |
| 3208 | /// keyboard with no `@` on it. |
| 3209 | /// |
| 3210 | /// Added 0.5.0, from goingson's contact form. |
| 3211 | Email, |
| 3212 | /// A URL. Same reasoning as [`Email`](Self::Email). |
| 3213 | /// |
| 3214 | /// Added 0.5.0, from goingson's contact-social and contact-feed forms. |
| 3215 | Url, |
| 3216 | /// A telephone number. Same reasoning as [`Email`](Self::Email), and the |
| 3217 | /// clearest case of it: the keyboard is a numeric pad rather than letters. |
| 3218 | /// |
| 3219 | /// Added 0.5.0, from goingson's contact-phone form. |
| 3220 | Tel, |
| 3221 | /// A calendar day, with no time of day in it. |
| 3222 | /// |
| 3223 | /// [`Email`](Self::Email)'s argument, and it carries further: a webview |
| 3224 | /// emits `type="date"`, which is a native picker, the platform's own |
| 3225 | /// validation, and on a touch device the date keyboard. Described as |
| 3226 | /// [`Text`](Self::Text) with a hint reading "YYYY-MM-DD", all three are |
| 3227 | /// lost and the hint is doing the platform's job in prose. |
| 3228 | /// |
| 3229 | /// The membership test passes on every host without stretching: a webview |
| 3230 | /// and a Tauri app emit the input, egui has a date picker, a terminal |
| 3231 | /// prompts for a day and can validate it, a CLI takes an argument. |
| 3232 | /// |
| 3233 | /// # The value is ISO 8601, `YYYY-MM-DD` |
| 3234 | /// |
| 3235 | /// Named here rather than left to each host, because a host that picks |
| 3236 | /// differently sends a server something it parses differently, and the |
| 3237 | /// failure is silent and per-host. It is `<input type="date">`'s own wire |
| 3238 | /// format, so the webview renderer owes nothing to honour it and the other |
| 3239 | /// hosts have one spelling to meet. [`DATE_FORMAT`] is the constant, and a |
| 3240 | /// test asserts this doc and that constant agree. |
| 3241 | /// |
| 3242 | /// Added 0.15.0, from the MNW server's git access-token expiry |
| 3243 | /// (`user_ssh_keys_tab.html`) and six further sites across the server and |
| 3244 | /// goingson. |
| 3245 | Date, |
| 3246 | /// A calendar day and a time of day together. |
| 3247 | /// |
| 3248 | /// Apart from [`Date`](Self::Date) because the question is different rather |
| 3249 | /// than more precise: "which day does this expire" and "at what moment does |
| 3250 | /// this publish" are asked by different screens and answered by different |
| 3251 | /// controls. A webview emits `type="datetime-local"` for one and |
| 3252 | /// `type="date"` for the other, and a host that collapsed them would ask |
| 3253 | /// half the tree for a precision it does not want. |
| 3254 | /// |
| 3255 | /// Both arrived together on measurement rather than on symmetry: 13 sites |
| 3256 | /// of each across the MNW server and goingson, and **zero** of `time`, |
| 3257 | /// `month` or `week`, which is why those are not here. A member added for a |
| 3258 | /// case nobody has is a member designed against nothing, which is |
| 3259 | /// [`File`](Self::File)'s reasoning about `accept` applied to a whole |
| 3260 | /// member. |
| 3261 | /// |
| 3262 | /// # The value is `YYYY-MM-DDTHH:MM`, local, with no zone |
| 3263 | /// |
| 3264 | /// `<input type="datetime-local">`'s own format, and the "local" is the |
| 3265 | /// load-bearing half: the value carries no offset and no `Z`, so the moment |
| 3266 | /// it names is only fixed once something supplies a zone. That is the app's |
| 3267 | /// business and not the description's. Seconds are absent, which is the |
| 3268 | /// browser's own default and is left as the rule rather than restated as a |
| 3269 | /// constraint. [`DATETIME_FORMAT`] is the constant. |
| 3270 | /// |
| 3271 | /// [`Field::min`] and [`Field::max`] already take "the host's own spelling |
| 3272 | /// of a bound", so a floor of *not in the past* needs nothing new here: it |
| 3273 | /// is a string in this same format. |
| 3274 | /// |
| 3275 | /// Added 0.15.0, from goingson's snooze picker and day planner and the MNW |
| 3276 | /// server's publish-at fields. |
| 3277 | DateTime, |
| 3278 | /// Several lines of text. |
| 3279 | Textarea, |
| 3280 | /// Several lines of text the user writes markdown in. |
| 3281 | /// |
| 3282 | /// The editing counterpart of prose a description carries as markdown |
| 3283 | /// source, and the reason it can exist at all is the same one that lets the |
| 3284 | /// source be carried: editing markdown is editing text, so a terminal, an |
| 3285 | /// immediate-mode host and a webview all have an honest answer, and none of |
| 3286 | /// them has to refuse. A kind that meant "rich text" in the WYSIWYG sense |
| 3287 | /// would have been a document model, and two of the three hosts would have |
| 3288 | /// had to draw something they cannot. |
| 3289 | /// |
| 3290 | /// What the mark buys over [`Textarea`](Self::Textarea) is that a renderer |
| 3291 | /// may offer the affordances markdown has and plain text does not — a |
| 3292 | /// preview, a syntax pass, a monospaced face for the source — and that a |
| 3293 | /// host reading the value back knows what it is holding. A renderer with |
| 3294 | /// none of that draws a textarea, which is why this is additive rather than |
| 3295 | /// a second control. |
| 3296 | /// |
| 3297 | /// It says nothing about **when** the value is saved. Autosave is a clock, |
| 3298 | /// clocks are not described here, and the four MNW editors this was measured |
| 3299 | /// against each keep their own. |
| 3300 | /// |
| 3301 | /// Sanitising stays where it already is for markdown that is only displayed: |
| 3302 | /// with the renderer, at the point markup is produced. Being described is |
| 3303 | /// not a safety property, and a host with its own sanitiser and its own |
| 3304 | /// content-security posture still owns both. |
| 3305 | /// |
| 3306 | /// Added 0.30.0, `f8ad0b32`, from four hand-written MNW section editors — |
| 3307 | /// `project-sections.js`, `blog-editor.js`, `partial-item-text-editor.js` |
| 3308 | /// and `wizard-item-sections.js` — which are one shape written four times. |
| 3309 | Rich, |
| 3310 | /// One of a fixed set, offered behind a control that shows one at a time. |
| 3311 | Select, |
| 3312 | /// One of a fixed set, with every option on screen at once. |
| 3313 | /// |
| 3314 | /// Not a presentation of [`Select`](Self::Select), which is the reading to |
| 3315 | /// resist: what differs is a property of the *question*. A choice that is |
| 3316 | /// consequential or irreversible has to be readable without opening |
| 3317 | /// anything, because a closed control shows one option and hides the rest, |
| 3318 | /// and the one it shows is whichever was current before the user had read |
| 3319 | /// the alternatives. audiofiles asks whether a library copies samples into |
| 3320 | /// its store or references them where they lie — which cannot be changed |
| 3321 | /// afterwards — and had already promoted that out of a checkbox by hand, |
| 3322 | /// with a comment giving this reason, before the description could say it. |
| 3323 | /// |
| 3324 | /// It was described here at 0.8.1 as "the one HTML input type this enum was |
| 3325 | /// missing", which was not true then and is not true now: `file` arrived at |
| 3326 | /// 0.11.0 and `date` and `datetime-local` at 0.15.0. Everything here is |
| 3327 | /// still an `<input type=...>`, a `<select>` or a `<textarea>`, and the way |
| 3328 | /// this enum grows is by a site being measured rather than by a list being |
| 3329 | /// completed, so "the last one" is not a claim it should make again. |
| 3330 | /// |
| 3331 | /// Added 0.8.1, from audiofiles' Add Library form. |
| 3332 | Radio, |
| 3333 | /// On or off. |
| 3334 | Checkbox, |
| 3335 | /// A file the user picks from wherever the host keeps files. |
| 3336 | /// |
| 3337 | /// Added 0.11.0, `844b5ae0`, from goingson's project-dashboard attachments |
| 3338 | /// column. It was filed as a router finding — a control whose destination is |
| 3339 | /// a host capability rather than an address — and splitting it is what made |
| 3340 | /// it two answers instead of one member satisfying neither. *Opening* a file |
| 3341 | /// is a one-way handoff and needs no new API. *Picking* one returns a value |
| 3342 | /// into a write, which is a form concern, which is this. |
| 3343 | /// |
| 3344 | /// The membership test passes on every host and not by a stretch: a Tauri |
| 3345 | /// app opens a native picker, a server renders `<input type="file">`, a |
| 3346 | /// terminal prompts for a path, a CLI takes an argument. That is closer to |
| 3347 | /// [`Email`](Self::Email), which exists because it changes the keyboard, |
| 3348 | /// than to anything bespoke. |
| 3349 | /// |
| 3350 | /// # The four things an upload says, and where each of them lives |
| 3351 | /// |
| 3352 | /// | axis | where | |
| 3353 | /// |---|---| |
| 3354 | /// | what it accepts | [`Field::accept`] | |
| 3355 | /// | one file or several | [`Field::multiple`] | |
| 3356 | /// | where the bytes go | the router's action, not here | |
| 3357 | /// | how far along it is | [`Awaiting`] on that action | |
| 3358 | /// |
| 3359 | /// Only the first two are this crate's, and that split is the answer to |
| 3360 | /// "describe an upload in full" rather than a gap in it. A destination is an |
| 3361 | /// address and this crate holds no addresses; progress is a live number and |
| 3362 | /// a description is built once, so the number is the renderer's to observe |
| 3363 | /// against the size [`Awaiting::amount`] carried before the transfer began. |
| 3364 | /// |
| 3365 | /// # How the file is handed over is the host's |
| 3366 | /// |
| 3367 | /// A drop area, a button opening a native picker, a path typed at a prompt: |
| 3368 | /// all three are the same field, and every measured site has the first. It |
| 3369 | /// is not described for the reason no gesture is — this crate owns no |
| 3370 | /// coordinates and no pointer, and a terminal that cannot be dropped on |
| 3371 | /// would be refusing a description it can otherwise honour completely. |
| 3372 | /// |
| 3373 | /// The first two were absent until 0.31.0, and the doc here said why: they |
| 3374 | /// were measured rather than deferred, `accept` appearing at zero sites in |
| 3375 | /// either app. The count was taken over goingson and Balanced Breakfast, and |
| 3376 | /// the MNW server is a third consumer with 14 of them. A member designed |
| 3377 | /// against nothing is still the rule; the measurement is what changed. |
| 3378 | File, |
| 3379 | /// Carried through the form and never shown. |
| 3380 | Hidden, |
| 3381 | |
| 3382 | |
| 3383 | /// The wire format a [`FieldKind::Date`] value takes: ISO 8601, `YYYY-MM-DD`. |
| 3384 | /// |
| 3385 | /// A constant rather than a sentence in a doc comment, because the reason to |
| 3386 | /// name the format at all is that a host picking its own would fail silently |
| 3387 | /// against a server parsing another. A host that cannot emit the native control |
| 3388 | /// still has one spelling to meet, and can say which one it meant. |
| 3389 | pub const DATE_FORMAT: &str = "%Y-%m-%d"; |
| 3390 | |
| 3391 | /// The wire format a [`FieldKind::DateTime`] value takes: `YYYY-MM-DDTHH:MM`, |
| 3392 | /// local, carrying no zone and no seconds. |
| 3393 | /// |
| 3394 | /// [`DATE_FORMAT`]'s sibling and there for its reason. The absent zone is a |
| 3395 | /// property of the value rather than an omission: the moment is not fixed until |
| 3396 | /// something outside the description supplies one. |
| 3397 | pub const DATETIME_FORMAT: &str = "%Y-%m-%dT%H:%M"; |
| 3398 | |
| 3399 | |
| 3400 | /// Whether the value the kind takes is a moment rather than a string. |
| 3401 | /// |
| 3402 | /// Named once here for the reason [`offers_options`](Self::offers_options) |
| 3403 | /// is: two kinds answer yes, and a host that has to parse or format a value |
| 3404 | /// needs to ask without spelling the pair out at each renderer. A third |
| 3405 | /// temporal kind should land here and nowhere else. |
| 3406 | /// |
| 3407 | /// The format each one takes is [`DATE_FORMAT`] and [`DATETIME_FORMAT`]. |
| 3408 | |
| 3409 | pub const |
| 3410 | matches! |
| 3411 | |
| 3412 | |
| 3413 | /// Whether the field is drawn at all. |
| 3414 | |
| 3415 | pub const |
| 3416 | !matches! |
| 3417 | |
| 3418 | |
| 3419 | /// Whether the value must be kept out of logs and diagnostics. |
| 3420 | |
| 3421 | pub const |
| 3422 | matches! |
| 3423 | |
| 3424 | |
| 3425 | /// Where the field's own label sits. |
| 3426 | /// |
| 3427 | /// A checkbox labels itself on the right of the box; everything else takes |
| 3428 | /// a label above. Both webview apps already do this and both special-case |
| 3429 | /// it inline, which is the tell that it belongs in the description. |
| 3430 | /// |
| 3431 | /// A [`Radio`](Self::Radio) is not one of them, and the near-miss is worth |
| 3432 | /// naming: its *options* each label themselves, but the field still asks a |
| 3433 | /// question above them, so the group takes a label like everything else. |
| 3434 | |
| 3435 | pub const |
| 3436 | matches! |
| 3437 | |
| 3438 | |
| 3439 | /// Whether the kind reads [`Field::options`]. |
| 3440 | /// |
| 3441 | /// Two kinds do, so the pair is named once here rather than spelled out at |
| 3442 | /// each renderer and again in [`Field::options`]' own doc, where "every |
| 3443 | /// kind but `Select`" was true for exactly one release. A third |
| 3444 | /// option-taking kind should land here and nowhere else. |
| 3445 | |
| 3446 | pub const |
| 3447 | matches! |
| 3448 | |
| 3449 | |
| 3450 | /// Whether the value runs to more than one line. |
| 3451 | /// |
| 3452 | /// Named once here for [`temporal`](Self::temporal)'s reason: two kinds |
| 3453 | /// answer yes, every renderer has to ask it before it can size anything, |
| 3454 | /// and a `matches!` per renderer is the pair drifting apart one member at a |
| 3455 | /// time. What a host does with the markdown, if anything, it reads from the |
| 3456 | /// kind itself; this is only whether one line is enough. |
| 3457 | |
| 3458 | pub const |
| 3459 | matches! |
| 3460 | |
| 3461 | |
| 3462 | /// Whether the value is a file the host picks rather than a string typed |
| 3463 | /// into a box. |
| 3464 | /// |
| 3465 | /// One member answers yes, which is [`visible`](Self::visible)'s and |
| 3466 | /// [`confidential`](Self::confidential)'s footing rather than a departure |
| 3467 | /// from it: the question gets a name because three renderers ask it before |
| 3468 | /// they can read [`Field::accept`] or [`Field::multiple`], and a `matches!` |
| 3469 | /// per renderer is where a second file-taking kind would go missing. |
| 3470 | |
| 3471 | pub const |
| 3472 | matches! |
| 3473 | |
| 3474 | |
| 3475 | |
| 3476 | /// A family of media a file can belong to. |
| 3477 | /// |
| 3478 | /// Three members, because three is what a media type's own first segment offers |
| 3479 | /// that a renderer can do anything with. `text` and `application` are families |
| 3480 | /// too and neither buys a disclosure — there is no preview of an |
| 3481 | /// `application/octet-stream` — so naming them would be a member added for a |
| 3482 | /// case nobody has. |
| 3483 | /// |
| 3484 | /// It is the answer to "which disclosure", not a validation rule. |
| 3485 | /// [`Field::accept`] is what a host filters on. |
| 3486 | |
| 3487 | |
| 3488 | |
| 3489 | /// A still picture. |
| 3490 | Image, |
| 3491 | /// Sound. |
| 3492 | Audio, |
| 3493 | /// Moving pictures, with or without sound. |
| 3494 | Video, |
| 3495 | |
| 3496 | |
| 3497 | |
| 3498 | /// The wildcard media type that means the whole family. |
| 3499 | /// |
| 3500 | /// `image/*` and its two siblings, which is what the measured sites write |
| 3501 | /// and what a webview puts in an `accept` attribute. Named here so the three |
| 3502 | /// renderers do not each spell the star. |
| 3503 | |
| 3504 | pub const |
| 3505 | match self |
| 3506 | SelfImage => "image/*", |
| 3507 | SelfAudio => "audio/*", |
| 3508 | SelfVideo => "video/*", |
| 3509 | |
| 3510 | |
| 3511 | |
| 3512 | /// The family a media type's first segment names, if it is one of these. |
| 3513 | /// |
| 3514 | /// Case-insensitive on the segment, because a media type is |
| 3515 | /// case-insensitive and half the tree writes them lowercase by habit rather |
| 3516 | /// than by rule. |
| 3517 | |
| 3518 | |
| 3519 | let = media_type.split_once?; |
| 3520 | if top.eq_ignore_ascii_case |
| 3521 | Some |
| 3522 | else if top.eq_ignore_ascii_case |
| 3523 | Some |
| 3524 | else if top.eq_ignore_ascii_case |
| 3525 | Some |
| 3526 | else |
| 3527 | None |
| 3528 | |
| 3529 | |
| 3530 | |
| 3531 | |
| 3532 | /// One entry in a file field's accept list. |
| 3533 | /// |
| 3534 | /// Three shapes rather than a string, and all three are in the measured sites: |
| 3535 | /// the MNW server writes `image/*`, `image/jpeg,image/png,image/webp`, |
| 3536 | /// `.zip,.dmg,.exe,.appimage,.deb,.tar.gz,.clap,.vst3` and, in one place, |
| 3537 | /// `.csv,text/csv`. A single string would carry all of them and answer nothing |
| 3538 | /// about any of them. |
| 3539 | /// |
| 3540 | /// # Why the list is not just a filter |
| 3541 | /// |
| 3542 | /// It is read twice. Once to decide what the picker offers, which any of the |
| 3543 | /// three shapes serves, and once to decide **which disclosure** the field gets: |
| 3544 | /// a preview for a picture, a duration or a waveform for a sound. There is one |
| 3545 | /// upload shape and a media upload is that shape with more of it shown, so the |
| 3546 | /// accept list is what says which more. [`family`](Self::family) is that |
| 3547 | /// question answered once here instead of a media-type parser in each renderer. |
| 3548 | /// |
| 3549 | /// # A suffix names no family, on purpose |
| 3550 | /// |
| 3551 | /// `.mp3` is audio in fact, and nothing here says so. A suffix-to-family table |
| 3552 | /// in a published crate is a mapping that goes stale, disagrees with the host's |
| 3553 | /// own idea of what a file is, and is wrong the first time somebody hands it a |
| 3554 | /// container. A call site that wants a picture's preview writes |
| 3555 | /// [`Family::Image`] or `image/jpeg`; a call site listing installer suffixes |
| 3556 | /// wants no disclosure anyway, which is the measured case. |
| 3557 | /// |
| 3558 | /// Added 0.31.0, `f7261a5a`. |
| 3559 | |
| 3560 | |
| 3561 | |
| 3562 | /// Every file of a family: `image/*` and its siblings. |
| 3563 | Family, |
| 3564 | /// One media type, written the way a media type is written: |
| 3565 | /// `image/jpeg`, `text/csv`. |
| 3566 | Type, |
| 3567 | /// One file-name suffix, written with its leading dot: `.zip`, `.tar.gz`. |
| 3568 | /// |
| 3569 | /// A suffix and not an extension, because `.tar.gz` is a measured site and |
| 3570 | /// is two dots. |
| 3571 | Suffix, |
| 3572 | |
| 3573 | |
| 3574 | |
| 3575 | /// The family this entry belongs to, when it names one. |
| 3576 | /// |
| 3577 | /// [`None`] for a [`Suffix`](Self::Suffix) and for any media type outside |
| 3578 | /// the three families, which is the honest answer rather than a missing |
| 3579 | /// one: the description did not say. |
| 3580 | |
| 3581 | |
| 3582 | match self |
| 3583 | SelfFamily => Some, |
| 3584 | SelfType => of_type, |
| 3585 | SelfSuffix => None, |
| 3586 | |
| 3587 | |
| 3588 | |
| 3589 | /// How a host that wants one string writes this entry. |
| 3590 | /// |
| 3591 | /// A webview's `accept` attribute takes exactly these spellings, and a |
| 3592 | /// terminal listing what it will take reads the same words. |
| 3593 | |
| 3594 | pub const |
| 3595 | match self |
| 3596 | SelfFamily => family.wildcard, |
| 3597 | SelfType | SelfSuffix => text, |
| 3598 | |
| 3599 | |
| 3600 | |
| 3601 | |
| 3602 | /// One option offered by a field [`FieldKind::offers_options`] accepts. |
| 3603 | /// |
| 3604 | /// Two strings, because the submitted value and the read label are different |
| 3605 | /// facts and every renderer that has tried to collapse them has had to |
| 3606 | /// un-collapse them later. `makeover-webview` invented this shape writing its |
| 3607 | /// form emitter and it is taken here unchanged; moving it down rather than |
| 3608 | /// re-deriving it is the point, since the second and third renderers were each |
| 3609 | /// going to arrive at a near-miss of it. |
| 3610 | /// `#[non_exhaustive]` as of 0.28.0, which every other type here that a |
| 3611 | /// renderer matches or builds has carried for releases. It was the omission |
| 3612 | /// that made [`unavailable`](Self::unavailable) a breaking change across 40 |
| 3613 | /// literal sites in six repos, and it arrives with that member so the price is |
| 3614 | /// paid once and never again. |
| 3615 | |
| 3616 | |
| 3617 | |
| 3618 | /// What is submitted. |
| 3619 | pub value: &'a str, |
| 3620 | /// What is read. |
| 3621 | pub label: &'a str, |
| 3622 | /// Why it cannot be picked right now, when it cannot. |
| 3623 | /// |
| 3624 | /// One member rather than an `available: bool` beside a reason, and the |
| 3625 | /// conflation is the point: an option greyed out with no explanation is a |
| 3626 | /// dead end the user cannot act on, and it is exactly the state the app |
| 3627 | /// that found this gap had to patch by hand with a line of prose under the |
| 3628 | /// control. Making the reason mandatory means the description cannot say |
| 3629 | /// the useless half. |
| 3630 | /// |
| 3631 | /// The option stays in the list. Dropping it is what an app does today, and |
| 3632 | /// it costs the user the knowledge that the thing exists at all — |
| 3633 | /// audiofiles' multi-sample mode appears on its own once a second sample is |
| 3634 | /// dropped, so a user who never sees it never learns what to drop. |
| 3635 | /// |
| 3636 | /// **Not [`Field::error`], and not [`Field::hint`].** An error is about the |
| 3637 | /// answer and a hint is standing help for the whole question; this is about |
| 3638 | /// one option among several, which is the level neither of those reaches. |
| 3639 | /// |
| 3640 | /// **Not disabled-the-state.** `State::Disabled` is about a whole field |
| 3641 | /// refusing to answer. This says the field is live and one of its answers |
| 3642 | /// is not available yet, which is a different sentence and the reason the |
| 3643 | /// tone rule matters here: the *other* options are still usable. |
| 3644 | /// |
| 3645 | /// Added 0.28.0, from audiofiles' instrument mode selector (`e761833e`). |
| 3646 | pub unavailable: , |
| 3647 | |
| 3648 | |
| 3649 | |
| 3650 | /// An option whose submitted value is also its label. |
| 3651 | |
| 3652 | pub const |
| 3653 | Selfnew |
| 3654 | |
| 3655 | |
| 3656 | /// An option that submits one string and reads as another. |
| 3657 | /// |
| 3658 | /// A constructor rather than a literal, which is what `#[non_exhaustive]` |
| 3659 | /// costs and buys: outside this crate the struct cannot be built by naming |
| 3660 | /// its members, so every call site goes through here and the next member |
| 3661 | /// added breaks none of them. |
| 3662 | |
| 3663 | pub const |
| 3664 | Self |
| 3665 | value, |
| 3666 | label, |
| 3667 | unavailable: None, |
| 3668 | |
| 3669 | |
| 3670 | |
| 3671 | /// The same option, not pickable yet, and why. |
| 3672 | /// |
| 3673 | /// Builder-shaped because the reason is the rare case: 39 of the 40 option |
| 3674 | /// sites measured across the tree do not have one. |
| 3675 | |
| 3676 | pub const |
| 3677 | self.unavailable = Some; |
| 3678 | self |
| 3679 | |
| 3680 | |
| 3681 | /// Whether the option can be picked right now. |
| 3682 | /// |
| 3683 | /// The predicate a renderer branches on, so that "unavailable" is read as |
| 3684 | /// one condition in one place rather than as `unavailable.is_some()` at |
| 3685 | /// three renderers, one of which will invert it. |
| 3686 | |
| 3687 | pub const |
| 3688 | self.unavailable.is_none |
| 3689 | |
| 3690 | |
| 3691 | |
| 3692 | /// One field of a form. |
| 3693 | /// |
| 3694 | /// Borrowed rather than owned: a description is built, read once by a renderer, |
| 3695 | /// and dropped. Nothing here outlives the screen it describes. |
| 3696 | /// |
| 3697 | /// # What it carries, and what it does not |
| 3698 | /// |
| 3699 | /// Stated here so the next renderer does not re-ask, which is what the first |
| 3700 | /// two both did. It carries everything a renderer needs to *draw* the field: |
| 3701 | /// its kind, what it is called, what it is asked for, its standing help, what |
| 3702 | /// is wrong with it now, whether it is compulsory, whether it hides behind a |
| 3703 | /// disclosure, its ghost text, and the options it offers. |
| 3704 | /// |
| 3705 | /// It does not carry the **current value**, and it is not going to. That is the |
| 3706 | /// one thing here that is genuinely renderer state: a webview reads it back out |
| 3707 | /// of the DOM, an immediate-mode renderer holds a `&mut` to the app's own field |
| 3708 | /// and writes through it, and a terminal keeps an edit buffer. A description |
| 3709 | /// that carried the value would have to carry a way to write it back, at which |
| 3710 | /// point it is a form model and no longer a description. |
| 3711 | /// |
| 3712 | /// **Constraints** are here and enforcement is not, which is one line rather |
| 3713 | /// than two. [`required`], [`max_length`], [`min`] and [`max`] are facts about |
| 3714 | /// the *question*, so a renderer can emit its host's idiom for each — an HTML |
| 3715 | /// attribute, a marked label, a clamped spinner — and the platform helps the |
| 3716 | /// user before anything is submitted. Deciding that a value is wrong stays with |
| 3717 | /// whoever validated, and [`error`] is that decision arriving back. |
| 3718 | /// |
| 3719 | /// The set stops before `pattern`, and stops there on both tests at once. A |
| 3720 | /// regex has an honest answer in a webview and none anywhere else: egui would |
| 3721 | /// have to run it per keystroke and decide what a half-typed value means, which |
| 3722 | /// is enforcement wearing description's clothes. And it is one site in goingson |
| 3723 | /// and none in Balanced Breakfast, against 8 and 1 for `maxlength`. Measured |
| 3724 | /// 2026-08-09, `2cbad3e2`. |
| 3725 | /// |
| 3726 | /// [`error`]: Field::error |
| 3727 | /// [`required`]: Field::required |
| 3728 | /// [`max_length`]: Field::max_length |
| 3729 | /// [`min`]: Field::min |
| 3730 | /// [`max`]: Field::max |
| 3731 | |
| 3732 | |
| 3733 | /// What kind of value it takes. |
| 3734 | pub kind: FieldKind, |
| 3735 | /// The name the value is submitted under. |
| 3736 | pub name: &'a str, |
| 3737 | /// What the user is asked for. |
| 3738 | pub label: &'a str, |
| 3739 | /// Standing help, shown whether or not anything is wrong. |
| 3740 | pub hint: , |
| 3741 | /// What is currently wrong with the value. |
| 3742 | pub error: , |
| 3743 | /// Ghost text shown while the field is empty. |
| 3744 | /// |
| 3745 | /// User-facing text, and it sits with `label` and `hint` rather than with |
| 3746 | /// the value because it is a property of the *question* and not of the |
| 3747 | /// answer. It lived renderer-side in `makeover-webview` until 0.8.0 for one |
| 3748 | /// reason and it was not a reading on where it belonged: adding a field to |
| 3749 | /// a published struct is a breaking change. |
| 3750 | /// |
| 3751 | /// Not a substitute for a label. A field labelled only by its placeholder |
| 3752 | /// loses its label the moment anything is typed, and no renderer here can |
| 3753 | /// make that not happen, so the description keeps both. |
| 3754 | pub placeholder: , |
| 3755 | /// The options offered, in the order they are offered. |
| 3756 | /// |
| 3757 | /// Empty for every kind [`FieldKind::offers_options`] rejects. A field |
| 3758 | /// described with no options is sayable on purpose: it is what an app with |
| 3759 | /// an unfinished-loading option list actually has, and a renderer showing |
| 3760 | /// an empty control says so on screen rather than in a log. |
| 3761 | /// |
| 3762 | /// Which option is *current* is not here. That is the value, and the value |
| 3763 | /// is renderer state. |
| 3764 | pub options: &'a [], |
| 3765 | /// What a file field takes, in the order a host offering the list shows it. |
| 3766 | /// |
| 3767 | /// Empty for every kind [`FieldKind::takes_files`] rejects, and empty is |
| 3768 | /// also a real answer for one that accepts it: a field that takes any file |
| 3769 | /// says so by listing nothing, which is what an `<input type="file">` with |
| 3770 | /// no `accept` does and what most of the measured sites are. |
| 3771 | /// |
| 3772 | /// It is a filter and it is the disclosure cue, and [`Accepted`]'s doc |
| 3773 | /// carries which reading is which. Nothing here validates: a host may hand |
| 3774 | /// back a file the list does not cover, exactly as a browser does when the |
| 3775 | /// user switches the picker to "All Files", and deciding a value is wrong |
| 3776 | /// stays with whoever validated. |
| 3777 | /// |
| 3778 | /// Added 0.31.0, `f7261a5a`. |
| 3779 | pub accept: &'a [], |
| 3780 | /// Whether more than one file may be picked at once. |
| 3781 | /// |
| 3782 | /// Only [`FieldKind::takes_files`] reads it. A multi-valued answer to any |
| 3783 | /// other question is a different shape — a set of options, a repeated |
| 3784 | /// group — and neither is this flag with a different kind beside it. |
| 3785 | /// |
| 3786 | /// False is the common case: 4 of the MNW server's 16 file inputs carry it. |
| 3787 | /// |
| 3788 | /// Added 0.31.0, `f7261a5a`. |
| 3789 | pub multiple: bool, |
| 3790 | /// Whether the form refuses to submit without it. |
| 3791 | pub required: bool, |
| 3792 | /// The longest the value may be, in characters. |
| 3793 | /// |
| 3794 | /// Added 0.11.0 with [`min`](Self::min) and [`max`](Self::max), joining |
| 3795 | /// [`required`](Self::required), which had been the only constraint here |
| 3796 | /// since before the crate wrote down that it carried none. |
| 3797 | pub max_length: , |
| 3798 | /// The lowest value accepted, as the host would write it. |
| 3799 | /// |
| 3800 | /// Text rather than a number, because the bound is only a number for some |
| 3801 | /// of the kinds that take one. goingson's own sites are `min="1"` on a |
| 3802 | /// duration and `min="2026-08-09T14:30"` on a datetime, and a numeric member |
| 3803 | /// could say the first and not the second. The [`kind`](Self::kind) already |
| 3804 | /// says how to read it, the same way it does for the value. |
| 3805 | pub min: , |
| 3806 | /// The highest value accepted, as the host would write it. See |
| 3807 | /// [`min`](Self::min). |
| 3808 | pub max: , |
| 3809 | /// The granularity the value moves in, as the host would write it. |
| 3810 | /// |
| 3811 | /// Text for [`min`](Self::min)'s reason, and it earns it twice over: the |
| 3812 | /// step of a date is a day and the step of a threshold is 0.01, and a |
| 3813 | /// numeric member could say one of them. |
| 3814 | /// |
| 3815 | /// Absent means the host's own granularity, which is the honest default |
| 3816 | /// rather than a missing value: a webview's `<input>` steps by 1 unless told |
| 3817 | /// otherwise, and that is the browser's rule and not this crate's to |
| 3818 | /// restate. It matters most to [`FieldKind::Range`], where the host default |
| 3819 | /// turns a 0-to-1 threshold into a two-position control, and it is not |
| 3820 | /// exclusive to it: a stepped [`Number`](FieldKind::Number) is the same fact |
| 3821 | /// about a typed value. |
| 3822 | /// |
| 3823 | /// Added 0.28.0 with [`FieldKind::Range`]. |
| 3824 | pub step: , |
| 3825 | /// Whether the field lives behind a "more options" disclosure. |
| 3826 | pub extended: bool, |
| 3827 | |
| 3828 | |
| 3829 | |
| 3830 | /// A plain required-nothing field of the given kind. |
| 3831 | |
| 3832 | pub const |
| 3833 | Self |
| 3834 | kind, |
| 3835 | name, |
| 3836 | label, |
| 3837 | hint: None, |
| 3838 | error: None, |
| 3839 | placeholder: None, |
| 3840 | options: &, |
| 3841 | accept: &, |
| 3842 | multiple: false, |
| 3843 | required: false, |
| 3844 | max_length: None, |
| 3845 | min: None, |
| 3846 | max: None, |
| 3847 | step: None, |
| 3848 | extended: false, |
| 3849 | |
| 3850 | |
| 3851 | |
| 3852 | /// A bounded number the user drags across its whole extent. |
| 3853 | /// |
| 3854 | /// The third under-described kind, and it gets a constructor for |
| 3855 | /// [`select`](Self::select)'s reason: a range is the one kind whose bounds |
| 3856 | /// are not a rule but the control itself, so a call site that forgot them |
| 3857 | /// has a slider with nothing to slide across. Taking them as arguments is |
| 3858 | /// what makes that unsayable. |
| 3859 | /// |
| 3860 | /// [`step`](Self::step) stays a field rather than a fourth argument. It is |
| 3861 | /// genuinely optional — the host's granularity is a real answer — and the |
| 3862 | /// two bounds are not. |
| 3863 | |
| 3864 | pub const |
| 3865 | Self |
| 3866 | min: Some, |
| 3867 | max: Some, |
| 3868 | ..Selfnew |
| 3869 | |
| 3870 | |
| 3871 | |
| 3872 | /// A file field, taking the given accept list. |
| 3873 | /// |
| 3874 | /// The fourth under-described kind and it gets a constructor for |
| 3875 | /// [`range`](Self::range)'s reason rather than [`select`](Self::select)'s: |
| 3876 | /// a file field with no accept list is not broken, it is a field that takes |
| 3877 | /// anything, and the hazard is the opposite one. A call site that meant to |
| 3878 | /// restrict and forgot has a picker offering every file on the machine and |
| 3879 | /// a server refusing the upload afterwards, which is the failure the list |
| 3880 | /// exists to move forward. Taking it as an argument is what makes an |
| 3881 | /// accidental omission a deliberate `&[]`. |
| 3882 | /// |
| 3883 | /// [`multiple`](Self::multiple) stays a field. One file is the common case |
| 3884 | /// and the honest default; several is the thing worth saying. |
| 3885 | |
| 3886 | pub const |
| 3887 | Self |
| 3888 | accept, |
| 3889 | ..Selfnew |
| 3890 | |
| 3891 | |
| 3892 | |
| 3893 | /// A select offering the given options. |
| 3894 | /// |
| 3895 | /// One of the two kinds under-described by [`Field::new`], so it gets a |
| 3896 | /// constructor rather than leaving every call site to remember that a |
| 3897 | /// select with an empty `options` renders as an empty select. |
| 3898 | |
| 3899 | pub const |
| 3900 | Selfoffering |
| 3901 | |
| 3902 | |
| 3903 | /// A radio group offering the given options. |
| 3904 | /// |
| 3905 | /// The other. Same hazard as [`select`](Self::select) and a worse one: a |
| 3906 | /// radio group with no options draws nothing at all, so a call site that |
| 3907 | /// forgot them has an empty rectangle rather than a visibly empty control. |
| 3908 | |
| 3909 | pub const |
| 3910 | Selfoffering |
| 3911 | |
| 3912 | |
| 3913 | /// The shared body of the two constructors that take options. |
| 3914 | /// |
| 3915 | /// Private, and keyed on the kind rather than exposed, because the two |
| 3916 | /// public names are the point: a call site says which question it is |
| 3917 | /// asking, not which flag it is setting. |
| 3918 | const |
| 3919 | kind: FieldKind, |
| 3920 | name: &'a str, |
| 3921 | label: &'a str, |
| 3922 | options: &'a [], |
| 3923 | |
| 3924 | Self |
| 3925 | options, |
| 3926 | ..Selfnew |
| 3927 | |
| 3928 | |
| 3929 | |
| 3930 | /// Whether the field is currently reporting a problem. |
| 3931 | /// |
| 3932 | /// Read this rather than testing `error.is_some()` at each renderer: the |
| 3933 | /// error state has to mark the field's whole group and not only the |
| 3934 | /// message, because a renderer with no descendant selectors (egui, a |
| 3935 | /// terminal) cannot find the group from the message. goingson already marks |
| 3936 | /// the group and Balanced Breakfast does not, so goingson's shape is the |
| 3937 | /// one taken here. |
| 3938 | |
| 3939 | pub const |
| 3940 | self.error.is_some |
| 3941 | |
| 3942 | |
| 3943 | /// Whether the field carries both ends of its extent. |
| 3944 | /// |
| 3945 | /// Only [`FieldKind::Range`] owes them, and it owes them absolutely: a |
| 3946 | /// slider with one end missing has no extent to draw. Named here rather |
| 3947 | /// than left to each renderer to test `min.is_some() && max.is_some()`, |
| 3948 | /// which is three renderers arriving at the same condition and one of them |
| 3949 | /// getting it wrong, and named as a question about the *field* rather than |
| 3950 | /// about the kind because the kind cannot see the bounds. |
| 3951 | /// |
| 3952 | /// It is a check and not a guarantee. Nothing here refuses to build an |
| 3953 | /// unbounded range — [`Field::range`] is what makes the bounded one easy — |
| 3954 | /// so a renderer asks this and falls back to whatever its host does |
| 3955 | /// honestly with a number. |
| 3956 | |
| 3957 | pub const |
| 3958 | self.min.is_some && self.max.is_some |
| 3959 | |
| 3960 | |
| 3961 | /// Whether anything in [`accept`](Self::accept) names a media family. |
| 3962 | /// |
| 3963 | /// The question a renderer asks before it decides to keep room for a |
| 3964 | /// preview, and it is deliberately the *whole list* rather than one entry: |
| 3965 | /// the media dropzone this was measured against takes `image/*,video/*`, so |
| 3966 | /// there is no single family to return and there is still a disclosure to |
| 3967 | /// offer. Which one it turns out to be is known once a file is picked, which |
| 3968 | /// is renderer-side and after the description is gone. |
| 3969 | /// |
| 3970 | /// False for an empty list, for a list of suffixes, and for `text/csv`. A |
| 3971 | /// renderer that wants the family of a particular entry reads |
| 3972 | /// [`Accepted::family`]. |
| 3973 | |
| 3974 | |
| 3975 | self.accept.iter.any |
| 3976 | |
| 3977 | |
| 3978 | |
| 3979 | /// How much room a placement asks for. |
| 3980 | /// |
| 3981 | /// A column says it, and so does a [`Field`]. An intent, so the actual floor |
| 3982 | /// stays with `makeover-geometry`. goingson's task table spells these as |
| 3983 | /// `minmax(200px, 1fr)`, `140px` and content-sized; only the first three words |
| 3984 | /// of that survive deferral. |
| 3985 | /// `#[non_exhaustive]`, for the reason [`Fill`] and [`FieldKind`] are: a |
| 3986 | /// renderer matches on this and a vocabulary that grows must not break every |
| 3987 | /// renderer when it does. |
| 3988 | |
| 3989 | |
| 3990 | |
| 3991 | /// Takes what it needs and no more. |
| 3992 | Content, |
| 3993 | /// A fixed share, the same at every width. |
| 3994 | Fixed, |
| 3995 | /// Absorbs whatever is left over. |
| 3996 | /// |
| 3997 | /// **Several fills divide what is left equally.** Stated because it would |
| 3998 | /// otherwise be undefined and each renderer would invent something, and |
| 3999 | /// stated this way because equal division is the only sharing rule that |
| 4000 | /// answers to "Any width, one answer" without a tiebreak: allocating in |
| 4001 | /// declaration order makes the result depend on the order the description |
| 4002 | /// was written in, which is a fact about the source file and not about the |
| 4003 | /// screen. It documents what both renderers already do — CSS grid gives |
| 4004 | /// `1fr 1fr`, ratatui gives each a `Constraint::Fill(1)` — rather than |
| 4005 | /// changing anything. |
| 4006 | /// |
| 4007 | /// So a row of fills is a legal thing to describe, and there is no rule |
| 4008 | /// against it. Measured 2026-08-16, every table in the tree uses exactly |
| 4009 | /// one, which is the discipline this would otherwise have had to forbid. |
| 4010 | Fill, |
| 4011 | |
| 4012 | |
| 4013 | /// What a member is worth when there is not room for all of them. |
| 4014 | /// |
| 4015 | /// Written for table columns and no longer only theirs. Three shapes ask the |
| 4016 | /// same question and this answers all three: a table too narrow for its |
| 4017 | /// columns, a row too narrow for its parts (see [`RowPart::priority`]), and a |
| 4018 | /// group of regions sharing one run of room -- goingson's tab strip and the |
| 4019 | /// [`Region::Band`] beside it, which is the case wiki `layout-room-and-fallback` |
| 4020 | /// was ruled on. It is what any member of a group is worth, not a table |
| 4021 | /// concept, and [`Fallback::Shed`] is what reads it. |
| 4022 | /// |
| 4023 | /// The doc below is the column argument, which is where the type was measured; |
| 4024 | /// the sentence that gave it away is [`Priority::Essential`]'s, which was |
| 4025 | /// already written about a row. |
| 4026 | /// |
| 4027 | /// Ordered: [`Priority::Optional`] drops first, [`Priority::Essential`] never |
| 4028 | /// drops. This replaces addressing columns by position, which is what both |
| 4029 | /// webview apps do today and is a live bug rather than only verbosity. goingson |
| 4030 | /// hides mobile columns with `nth-child(n+5)` against a seven-column table, so |
| 4031 | /// inserting a column silently hides the wrong one. |
| 4032 | /// `#[non_exhaustive]`, same reasoning as [`Width`]. Note the ordering is the |
| 4033 | /// whole point of the type, so a new tier has to be declared in its place in |
| 4034 | /// the sequence rather than appended. |
| 4035 | |
| 4036 | |
| 4037 | |
| 4038 | /// Dropped first. |
| 4039 | Optional, |
| 4040 | /// Dropped once the optional members are gone. |
| 4041 | Secondary, |
| 4042 | /// Never dropped. Without it the group does not identify itself. |
| 4043 | Essential, |
| 4044 | |
| 4045 | |
| 4046 | /// How much room a group has, measured against its own allocation. |
| 4047 | /// |
| 4048 | /// Never authored. A renderer computes it from what the group was given and |
| 4049 | /// what the group's own contents ask for, in that renderer's units: a webview |
| 4050 | /// from `min-content` under a container query, a terminal from cell widths, |
| 4051 | /// egui from the galley. Nothing in the description says a number, which is the |
| 4052 | /// point -- an authored breakpoint rots and this cannot. |
| 4053 | /// |
| 4054 | /// # Why not [`Depth`]-style two members and no more |
| 4055 | /// |
| 4056 | /// Two is what the measurement supports. The goingson case that produced this |
| 4057 | /// type is a window 913px wide -- makeover-geometry's `SizeClass::Expanded` -- |
| 4058 | /// holding a group that has run out of room. A third tier would be a guess |
| 4059 | /// about a shape nothing in the tree has yet. |
| 4060 | /// |
| 4061 | /// # Why it is not `SizeClass` |
| 4062 | /// |
| 4063 | /// Because 913 is exactly the case that proves they are different facts. The |
| 4064 | /// window is roomy and the group is not, so a type that answered for both would |
| 4065 | /// have to be wrong about one of them. Sharing the name would also invite |
| 4066 | /// `@media` thinking straight back in, which is what put a `position: absolute` |
| 4067 | /// in goingson's stylesheet in the first place. Container semantics instead: a |
| 4068 | /// group narrowed by a sidebar behaves the same as one narrowed by the window, |
| 4069 | /// and there is one code path rather than two. |
| 4070 | /// |
| 4071 | /// Ordered least room first, [`Priority`]'s convention, so a group nesting |
| 4072 | /// another takes the minimum of the two and relief still resolves inside-out. |
| 4073 | |
| 4074 | |
| 4075 | |
| 4076 | /// Not everything the group contains fits, and the group's [`Fallback`] |
| 4077 | /// decides what happens. |
| 4078 | Tight, |
| 4079 | /// Everything fits as described. |
| 4080 | Ample, |
| 4081 | |
| 4082 | |
| 4083 | /// What a group does when it is [`Room::Tight`]. |
| 4084 | /// |
| 4085 | /// Authored, and required: the field carrying this has no `Default` and a group |
| 4086 | /// cannot be described without saying what it does when it runs out of room. |
| 4087 | /// Max ruled on that 2026-08-18 -- more intentionality from layout designers is |
| 4088 | /// acceptable so long as the constraints are solvable, because the goal is |
| 4089 | /// enabling good layouts rather than rescuing bad ones. A default here would be |
| 4090 | /// the crate guessing, and the guess would be silently wrong on the screens |
| 4091 | /// that matter. |
| 4092 | /// |
| 4093 | /// Relief resolves inside-out. A group asks its children to fall back before |
| 4094 | /// falling back itself, or an outer group collapses while an inner one still |
| 4095 | /// had slack. |
| 4096 | /// |
| 4097 | /// # No `Swap` |
| 4098 | /// |
| 4099 | /// An authored alternate group for the tight case is deliberately out of the |
| 4100 | /// first cut. It doubles the description for that group and the two halves can |
| 4101 | /// drift, which is the failure this vocabulary exists to end. Add it when a |
| 4102 | /// site proves it needs one. |
| 4103 | /// |
| 4104 | /// `#[non_exhaustive]`, [`Width`]'s reasoning. Unlike [`Priority`] there is no |
| 4105 | /// order to preserve, so a member can be appended. |
| 4106 | |
| 4107 | |
| 4108 | |
| 4109 | /// One row becomes two. Every member stays, in the order described. |
| 4110 | Wrap, |
| 4111 | /// A row becomes a column. Every member stays, full width. |
| 4112 | Stack, |
| 4113 | /// Members drop by [`Priority`], down to [`Priority::Essential`]. |
| 4114 | /// |
| 4115 | /// What a narrow table already does with its columns, applied to a group. |
| 4116 | /// What drops is gone from the screen, so this is right when the dropped |
| 4117 | /// members are facts the reader can do without and wrong when they are the |
| 4118 | /// only way to act. |
| 4119 | Shed, |
| 4120 | /// The members [`Shed`](Self::Shed) would drop move into one overflow |
| 4121 | /// control instead. |
| 4122 | /// |
| 4123 | /// The answer when a group holds actions. A control is not a fact: dropping |
| 4124 | /// it does not cost the reader a detail, it costs them the only way to act, |
| 4125 | /// which is [`RowPart::priority`]'s argument one level up. |
| 4126 | Menu, |
| 4127 | |
| 4128 | |
| 4129 | /// One column of a table. |
| 4130 | /// |
| 4131 | /// Described once. The grid track, the cell order and the drop behaviour are |
| 4132 | /// all derived from this, rather than being three hand-written encodings that |
| 4133 | /// must agree and are never checked against each other. |
| 4134 | |
| 4135 | |
| 4136 | /// The heading, and the name the cell is addressed by. |
| 4137 | pub name: &'a str, |
| 4138 | /// How much room it asks for. |
| 4139 | pub width: Width, |
| 4140 | /// What it is worth when room runs out. |
| 4141 | pub priority: Priority, |
| 4142 | /// Whether the user can reorder the table by this column. |
| 4143 | /// |
| 4144 | /// `ce620871`. What reordering *calls* is not here — that is an address, and |
| 4145 | /// this crate names none — so a host pairs this with the route the way it |
| 4146 | /// pairs a row's parts with the row's activation. This says the affordance |
| 4147 | /// exists, which is what a renderer needs to draw a header a user can press |
| 4148 | /// rather than a heading they cannot. |
| 4149 | pub sortable: bool, |
| 4150 | /// Which way the table is ordered by this column, if it is. |
| 4151 | /// |
| 4152 | /// `None` on every column but the one in force. A renderer draws the caret |
| 4153 | /// from this and a webview sets `aria-sort`, which is why it is per column |
| 4154 | /// rather than a single fact on the table: the host idiom is a property of |
| 4155 | /// the header cell. |
| 4156 | /// |
| 4157 | /// Independent of [`sortable`](Self::sortable) rather than implied by it, |
| 4158 | /// because both combinations mean something. A column sorted and not |
| 4159 | /// sortable is a list ordered by a key the user cannot change, which is a |
| 4160 | /// real thing to describe and a caret worth drawing. |
| 4161 | pub sorted: , |
| 4162 | |
| 4163 | |
| 4164 | /// Which way a column is ordered. |
| 4165 | /// |
| 4166 | /// Two, because there is no third. "Unsorted" is [`Column::sorted`] being |
| 4167 | /// `None`, and folding it in here would be the same absence said twice. |
| 4168 | |
| 4169 | |
| 4170 | /// Smallest, earliest or first alphabetically at the top. |
| 4171 | Ascending, |
| 4172 | /// The other way. |
| 4173 | Descending, |
| 4174 | |
| 4175 | |
| 4176 | |
| 4177 | /// The other direction, for a header that flips when pressed. |
| 4178 | |
| 4179 | pub const |
| 4180 | match self |
| 4181 | SelfAscending => SelfDescending, |
| 4182 | SelfDescending => SelfAscending, |
| 4183 | |
| 4184 | |
| 4185 | |
| 4186 | /// What a webview writes into `aria-sort`. |
| 4187 | /// |
| 4188 | /// Named here rather than in the webview renderer because a terminal and an |
| 4189 | /// immediate-mode painter both want the same two words for a caret's label, |
| 4190 | /// and three renderers picking their own is the drift this crate ends. |
| 4191 | |
| 4192 | pub const |
| 4193 | match self |
| 4194 | SelfAscending => "ascending", |
| 4195 | SelfDescending => "descending", |
| 4196 | |
| 4197 | |
| 4198 | |
| 4199 | /// The caret a renderer draws for this direction. |
| 4200 | /// |
| 4201 | /// Here for [`as_str`](Self::as_str)'s reason, said about a glyph rather |
| 4202 | /// than a word: three renderers picking their own is the drift this crate |
| 4203 | /// ends. They had picked their own — two on the solid triangles and |
| 4204 | /// `makeover-webview` on the arrows U+2191/U+2193 — and agreeing by |
| 4205 | /// coincidence in three files is not agreement. |
| 4206 | /// |
| 4207 | /// Settled 2026-08-16 (Max): the solid triangles, U+25B2 and U+25BC. The |
| 4208 | /// reason generalizes past this pair and is the house rule now — prefer the |
| 4209 | /// bolder, simpler glyph over the thinner or more complicated one. A third |
| 4210 | /// spelling is not open for re-argument. |
| 4211 | /// |
| 4212 | /// **Bare, with no spacing.** Where the gap goes is each renderer's |
| 4213 | /// business: `makeover-tui` and `makeover-immediate` carry a leading space |
| 4214 | /// inside their `TableStyle` string and a webview emits its own in |
| 4215 | /// `content`, so folding a space in here would make one of the two wrong. |
| 4216 | /// |
| 4217 | /// Neither face the web apps self-host carries these — IBM Plex Mono has one |
| 4218 | /// glyph in the whole geometric-shapes block and Lato has none — so a |
| 4219 | /// browser falls back per glyph until the in-house face ships with them |
| 4220 | /// drawn in (makeover `6d6d9146`, wiki `typography-standard`). Cosmetic |
| 4221 | /// drift in one renderer, not a reason to spell it three ways. |
| 4222 | |
| 4223 | pub const |
| 4224 | match self |
| 4225 | SelfAscending => "\u{25B2}", |
| 4226 | SelfDescending => "\u{25BC}", |
| 4227 | |
| 4228 | |
| 4229 | |
| 4230 | |
| 4231 | |
| 4232 | /// A column that absorbs slack and drops after the optional ones. |
| 4233 | |
| 4234 | pub const |
| 4235 | Self |
| 4236 | name, |
| 4237 | width: Fill, |
| 4238 | priority: Secondary, |
| 4239 | sortable: false, |
| 4240 | sorted: None, |
| 4241 | |
| 4242 | |
| 4243 | |
| 4244 | /// Whether this column survives at the given cutoff. |
| 4245 | /// |
| 4246 | /// A renderer narrows by raising the cutoff, and never by counting |
| 4247 | /// positions. |
| 4248 | |
| 4249 | pub const |
| 4250 | >= |
| 4251 | |
| 4252 | |
| 4253 | |
| 4254 | /// What a table cell holds. |
| 4255 | /// |
| 4256 | /// [`RowPart`] for tables, and it exists for the same reason: a part that |
| 4257 | /// carries a control is not text, and a renderer with one class for the whole |
| 4258 | /// cell paints it as though it were. `makeover-webview` emitted a single |
| 4259 | /// `.cell` until 0.25.0, so a button in a cell inherited the cell's content |
| 4260 | /// colour, which is the exact drift [`RowPart::intent`] prevents for rows and |
| 4261 | /// prevented for nothing here. |
| 4262 | /// |
| 4263 | /// Four members, and the count is what quasi's `Cell` was measured to carry: |
| 4264 | /// a value, tokens (33 cells across 22 server templates), actions (30 rows |
| 4265 | /// carrying a control, 5 beside a value) and a link (35 cells across 18 |
| 4266 | /// templates). Nothing was added past what something holds. |
| 4267 | /// |
| 4268 | /// `#[non_exhaustive]` for [`RowPart`]'s reason: growth here must not be a |
| 4269 | /// lockstep event across three renderers. |
| 4270 | /// |
| 4271 | /// # No hover-reveal |
| 4272 | /// |
| 4273 | /// [`RowPart`] carried a `revealed_on_hover` until 0.13.0 retired it, and this |
| 4274 | /// enum never gets one. A cell's actions are shown at rest in every consumer |
| 4275 | /// measured, and a member nothing uses is one three renderers owe an answer |
| 4276 | /// for. |
| 4277 | |
| 4278 | |
| 4279 | |
| 4280 | /// The cell's own text. |
| 4281 | Value, |
| 4282 | /// Small labelled things in the cell: a status badge, a chip. |
| 4283 | Tokens, |
| 4284 | /// Controls that act on what the row is about. |
| 4285 | Actions, |
| 4286 | /// The cell's value, where the value is itself a link. |
| 4287 | Link, |
| 4288 | |
| 4289 | |
| 4290 | |
| 4291 | /// The content intent the part takes. |
| 4292 | /// |
| 4293 | /// One part is text and three are not, so three answer with the intent |
| 4294 | /// inheriting already gives. That is [`RowPart::intent`]'s shape with the |
| 4295 | /// text side narrower: a cell's secondary and muted readings are the |
| 4296 | /// column's business, not the cell's. |
| 4297 | |
| 4298 | pub const |
| 4299 | match self |
| 4300 | SelfValue => "content", |
| 4301 | // A token carries its own tone, and a part-level intent underneath |
| 4302 | // it would fight the token sitting on it. |
| 4303 | SelfTokens => "content", |
| 4304 | // Actions carry controls rather than text. |
| 4305 | SelfActions => "content", |
| 4306 | // A link takes the action colour from the control it is, rather |
| 4307 | // than the cell's text colour from the cell it sits in. |
| 4308 | SelfLink => "content", |
| 4309 | |
| 4310 | |
| 4311 | |
| 4312 | |
| 4313 | /// A named dimension a set can be narrowed by. |
| 4314 | /// |
| 4315 | /// One word for six things that were six mechanisms. MNW's discover page filters |
| 4316 | /// by free text, a flat any-of over item types, a tree of tags, a numeric range |
| 4317 | /// over price, a nested one-of over AI tier, and a browse position in the tag |
| 4318 | /// tree held separately from the tag selection — and the last two being separate |
| 4319 | /// is the whole reason a filter row there needs a tick box *and* a chevron. The |
| 4320 | /// panel is a mixed bag of hand-written controls because nothing named the thing |
| 4321 | /// they all are. |
| 4322 | /// |
| 4323 | /// Deliberately wider than that one page. audiofiles' library browser and |
| 4324 | /// goingson's filters are the same shape, and a word that only fitted discover |
| 4325 | /// would be discover's markup with a neutral name on it. |
| 4326 | /// |
| 4327 | /// # What it does not say |
| 4328 | /// |
| 4329 | /// **What picking a value calls.** This crate names no address, so a facet is |
| 4330 | /// paired with routes the way a column's [`sortable`](Column::sortable) flag is |
| 4331 | /// paired with what reordering calls. |
| 4332 | /// |
| 4333 | /// **How a tree is drawn.** Indented rows, a column of panes, a breadcrumb and a |
| 4334 | /// list: all four are honest renderings of the same described facet, and a |
| 4335 | /// terminal will not pick the same one a browser does. [`FacetValue::depth`] is |
| 4336 | /// what a renderer needs to draw any of them; the choice is not described. |
| 4337 | /// |
| 4338 | /// **Which values to show.** A tag tree has thousands of nodes and a panel shows |
| 4339 | /// a handful. Deciding which handful is the app's — it is the same question as |
| 4340 | /// which rows go in a table, and no table member answers it either. |
| 4341 | |
| 4342 | |
| 4343 | |
| 4344 | /// What the dimension is called, as the user reads it. |
| 4345 | pub name: &'a str, |
| 4346 | /// How many of its values may be in force, and in what shape. |
| 4347 | pub mode: Selecting, |
| 4348 | /// The values on offer, in the order they are drawn. |
| 4349 | /// |
| 4350 | /// A [`Selecting::Text`] facet has none: the value is whatever was typed, |
| 4351 | /// and a description that listed the possible strings would be listing the |
| 4352 | /// corpus. A [`Selecting::Range`] facet has none either, for the reason |
| 4353 | /// [`FieldKind::Range`] takes bounds rather than options — the ends are the |
| 4354 | /// question and the values between them are not enumerable. |
| 4355 | pub values: &'a [], |
| 4356 | |
| 4357 | |
| 4358 | |
| 4359 | /// A dimension with values to pick from. |
| 4360 | |
| 4361 | pub const |
| 4362 | Self |
| 4363 | |
| 4364 | |
| 4365 | /// Whether the facet is narrowing the set right now. |
| 4366 | /// |
| 4367 | /// The question a renderer asks to decide whether to offer a way out of it, |
| 4368 | /// and the reason it is derived rather than carried: a facet with nothing |
| 4369 | /// standing is unengaged by construction, so a member saying so could |
| 4370 | /// disagree with the values beside it. [`Standing::Inherited`] does not |
| 4371 | /// count — something further up is what is doing the narrowing, and clearing |
| 4372 | /// a child that was never picked clears nothing. |
| 4373 | /// |
| 4374 | /// Always false for [`Selecting::Text`] and [`Selecting::Range`], which |
| 4375 | /// carry no values. A host that wants a clear affordance on those knows |
| 4376 | /// whether its own box is empty; the description does not hold the typed |
| 4377 | /// string. |
| 4378 | |
| 4379 | |
| 4380 | self.values.iter.any |
| 4381 | |
| 4382 | |
| 4383 | /// The deepest value in the facet, or zero when it is flat. |
| 4384 | /// |
| 4385 | /// What an indenting renderer needs to reserve a gutter before it draws the |
| 4386 | /// first row, which is "First paint is final paint" applied to a tree: a |
| 4387 | /// gutter widened as deeper values arrive is the reflow that rule forbids. |
| 4388 | |
| 4389 | |
| 4390 | self.values |
| 4391 | .iter |
| 4392 | .map |
| 4393 | .max |
| 4394 | .unwrap_or |
| 4395 | |
| 4396 | |
| 4397 | |
| 4398 | /// How many of a [`Facet`]'s values may be in force, and in what shape. |
| 4399 | /// |
| 4400 | /// Five, and the fifth is what made this an enum rather than a bool. `one-of`, |
| 4401 | /// `any-of`, a range and free text are the four a form vocabulary already has in |
| 4402 | /// [`FieldKind`]; a tree's selection is none of them, and describing tags as |
| 4403 | /// any-of was what forced browsing to be a second mechanism beside filtering. |
| 4404 | |
| 4405 | |
| 4406 | |
| 4407 | /// Exactly one value, and picking another replaces it. |
| 4408 | /// |
| 4409 | /// MNW's AI tier, whose three options are nested ranges rather than |
| 4410 | /// independent values, so two of them at once means nothing. |
| 4411 | OneOf, |
| 4412 | /// Any number of values, each independent of the others. |
| 4413 | AnyOf, |
| 4414 | /// A low end, a high end, or both. |
| 4415 | /// |
| 4416 | /// Carries no values for [`FieldKind::Range`]'s reason: the ends are the |
| 4417 | /// question. |
| 4418 | Range, |
| 4419 | /// Whatever the user types. |
| 4420 | Text, |
| 4421 | /// A position in a tree, edited by taking branches in and pruning branches |
| 4422 | /// out. |
| 4423 | /// |
| 4424 | /// The one mode that is not reducible to the others, and the one gesture |
| 4425 | /// that replaced two. Picking a value narrows the set to it *and* reveals |
| 4426 | /// its children, so browsing a tree and filtering by it stop being separate |
| 4427 | /// mechanisms with separate state. What a selection then is: a set of |
| 4428 | /// branches taken and a set pruned, resolved nearest-ancestor-first, so |
| 4429 | /// `music` in and `music/synths` out is sayable and no flat mode can say it. |
| 4430 | /// |
| 4431 | /// Resolution happens in the app, and what reaches a renderer is the |
| 4432 | /// [`Standing`] each drawn value ended up with. A renderer walking ancestors |
| 4433 | /// itself would be a renderer that can disagree with the results beside it. |
| 4434 | Subtree, |
| 4435 | |
| 4436 | |
| 4437 | |
| 4438 | /// Whether the mode picks from values the description lists. |
| 4439 | /// |
| 4440 | /// False for [`Text`](Self::Text) and [`Range`](Self::Range), which are the |
| 4441 | /// two whose answer is not one of a set. A renderer asks this before it |
| 4442 | /// looks at [`Facet::values`], the way it asks |
| 4443 | /// [`FieldKind::offers_options`] before it looks at [`Field::options`]. |
| 4444 | |
| 4445 | pub const |
| 4446 | matches! |
| 4447 | |
| 4448 | |
| 4449 | /// Whether a value can be pruned as well as picked. |
| 4450 | /// |
| 4451 | /// [`Subtree`](Self::Subtree) alone. Excluding a value from a flat facet is |
| 4452 | /// the same fact as not picking it, so an exclude affordance there would be |
| 4453 | /// a second control for a state the first one already holds. |
| 4454 | |
| 4455 | pub const |
| 4456 | matches! |
| 4457 | |
| 4458 | |
| 4459 | /// Whether picking a second value keeps the first. |
| 4460 | |
| 4461 | pub const |
| 4462 | matches! |
| 4463 | |
| 4464 | |
| 4465 | |
| 4466 | /// One value a [`Facet`] offers, as it currently stands. |
| 4467 | |
| 4468 | |
| 4469 | |
| 4470 | /// What identifies it, and what a host keys its route on. |
| 4471 | /// |
| 4472 | /// [`Choice::value`]'s split, and a tree is why it is not optional: two |
| 4473 | /// leaves under different parents are legitimately both called "Ambient", |
| 4474 | /// and the path is the only thing telling them apart. It is also what |
| 4475 | /// nearest-ancestor-wins resolves over, so an app that carried only labels |
| 4476 | /// could not compute the [`standing`](Self::standing) it hands back here. |
| 4477 | pub value: &'a str, |
| 4478 | /// What it is called, as the user reads it. |
| 4479 | /// |
| 4480 | /// The leaf's own name rather than its path: a facet drawn as an indented |
| 4481 | /// tree repeats every ancestor on every line otherwise, and one drawn as a |
| 4482 | /// breadcrumb has the ancestors already. |
| 4483 | pub label: &'a str, |
| 4484 | /// How many members of the set carry it. |
| 4485 | /// |
| 4486 | /// Optional, and settled that way rather than made mandatory: a count is a |
| 4487 | /// measured fact the app may not have. Counting a tag subtree under an |
| 4488 | /// active text search is a second query, and an app that will not pay for it |
| 4489 | /// should be able to describe the facet anyway rather than write a zero that |
| 4490 | /// reads as "none of them". That is [`Awaiting::amount`]'s rule in a second |
| 4491 | /// place — state a number when it was measured, and nothing when it was not. |
| 4492 | pub count: , |
| 4493 | /// Whether it is narrowing the set, and how it came to be. |
| 4494 | pub standing: Standing, |
| 4495 | /// How far down the tree it sits, counting from zero at the root. |
| 4496 | /// |
| 4497 | /// Always zero for a flat facet, which is what makes an indenting renderer |
| 4498 | /// one code path rather than two. A renderer that draws no tree at all still |
| 4499 | /// reads this, since a value's depth is what distinguishes two same-named |
| 4500 | /// leaves under different parents. |
| 4501 | pub depth: u8, |
| 4502 | /// Whether taking it reveals values under it. |
| 4503 | /// |
| 4504 | /// Distinct from having a nonzero [`depth`](Self::depth): a leaf deep in the |
| 4505 | /// tree branches no further, and a root with children does. Both facts are |
| 4506 | /// needed and neither implies the other, which is why the pair is two |
| 4507 | /// members rather than one count. |
| 4508 | pub branching: bool, |
| 4509 | |
| 4510 | |
| 4511 | |
| 4512 | /// An unpicked value at the root of the facet. |
| 4513 | |
| 4514 | pub const |
| 4515 | Self |
| 4516 | value, |
| 4517 | label, |
| 4518 | count: None, |
| 4519 | standing: Open, |
| 4520 | depth: 0, |
| 4521 | branching: false, |
| 4522 | |
| 4523 | |
| 4524 | |
| 4525 | /// A value whose identifier is also what the user reads. |
| 4526 | /// |
| 4527 | /// [`Choice::of`]'s convenience, and it is the flat case: a type or a tier |
| 4528 | /// is its own name, and only a tree needs a path that is not one. |
| 4529 | |
| 4530 | pub const |
| 4531 | Selfnew |
| 4532 | |
| 4533 | |
| 4534 | /// How many members carry it, when that was measured. |
| 4535 | |
| 4536 | pub const |
| 4537 | self.count = Some; |
| 4538 | self |
| 4539 | |
| 4540 | |
| 4541 | /// How it stands in the current selection. |
| 4542 | |
| 4543 | pub const |
| 4544 | self.standing = standing; |
| 4545 | self |
| 4546 | |
| 4547 | |
| 4548 | /// Where it sits in the tree, and whether anything hangs off it. |
| 4549 | |
| 4550 | pub const |
| 4551 | self.depth = depth; |
| 4552 | self.branching = branching; |
| 4553 | self |
| 4554 | |
| 4555 | |
| 4556 | |
| 4557 | /// Whether a [`FacetValue`] is narrowing the set, and how it came to be. |
| 4558 | /// |
| 4559 | /// Four rather than a bool, and the two extra members are what a tree costs. A |
| 4560 | /// pruned branch and an untaken one are not the same state — one was decided |
| 4561 | /// against and the other was never reached — and a child under a taken parent is |
| 4562 | /// in force without anybody having picked it. A renderer given a bool either |
| 4563 | /// marks every descendant of a taken branch, which reads as forty deliberate |
| 4564 | /// choices, or marks none of them, which reads as unfiltered. |
| 4565 | |
| 4566 | |
| 4567 | |
| 4568 | /// Not picked, and nothing above it is either. |
| 4569 | |
| 4570 | Open, |
| 4571 | /// Picked here. The set is narrowed to it and whatever hangs off it. |
| 4572 | Taken, |
| 4573 | /// In force because something above it was taken. |
| 4574 | Inherited, |
| 4575 | /// Pruned out, though something above it was taken. |
| 4576 | /// |
| 4577 | /// The state that only [`Selecting::Subtree`] can reach, and the reason |
| 4578 | /// exclusion is drawn as a visible affordance beside each label rather than |
| 4579 | /// as a modifier on the ordinary one: a gesture a terminal cannot express is |
| 4580 | /// a gesture half the renderers would have to leave out, and an affordance |
| 4581 | /// nothing teaches is one users do not find. |
| 4582 | Pruned, |
| 4583 | |
| 4584 | |
| 4585 | |
| 4586 | /// Whether the user decided this value, either way. |
| 4587 | /// |
| 4588 | /// True for [`Taken`](Self::Taken) and [`Pruned`](Self::Pruned) — both are |
| 4589 | /// choices, and both are things a "clear this" affordance has to clear. |
| 4590 | /// [`Inherited`](Self::Inherited) is not: clearing it clears nothing, |
| 4591 | /// because the decision is further up. |
| 4592 | |
| 4593 | pub const |
| 4594 | matches! |
| 4595 | |
| 4596 | |
| 4597 | /// Whether the value narrows the set in. |
| 4598 | /// |
| 4599 | /// [`Taken`](Self::Taken) and [`Inherited`](Self::Inherited): one was picked |
| 4600 | /// and one came down from above, and to the set they mean the same thing. |
| 4601 | /// The pair is named here so a renderer colouring in-force values does not |
| 4602 | /// have to know which is which. |
| 4603 | |
| 4604 | pub const |
| 4605 | matches! |
| 4606 | |
| 4607 | |
| 4608 | /// The content intent the value takes. |
| 4609 | /// |
| 4610 | /// [`Pruned`](Self::Pruned) reads back a step, which is the three-tone rule |
| 4611 | /// above rather than a new decision: a pruned branch is still a live control |
| 4612 | /// — pressing it takes the prune off — so it may not wear `content-muted`, |
| 4613 | /// and it is not the thing itself either. |
| 4614 | |
| 4615 | pub const |
| 4616 | match self |
| 4617 | SelfTaken | SelfInherited | SelfOpen => "content", |
| 4618 | SelfPruned => "content-secondary", |
| 4619 | |
| 4620 | |
| 4621 | |
| 4622 | |
| 4623 | |
| 4624 | |
| 4625 | use *; |
| 4626 | |
| 4627 | |
| 4628 | |
| 4629 | // The editing counterpart of markdown prose is still text: every host |
| 4630 | // can draw it, which is the whole reason the kind was addable. |
| 4631 | assert!; |
| 4632 | assert!; |
| 4633 | assert!; |
| 4634 | // It is not a chooser and not a moment. |
| 4635 | assert!; |
| 4636 | assert!; |
| 4637 | assert!; |
| 4638 | |
| 4639 | |
| 4640 | |
| 4641 | |
| 4642 | // Excluding a value from a flat facet is the same fact as not picking |
| 4643 | // it, so the affordance exists in exactly one mode. |
| 4644 | assert!; |
| 4645 | for mode in |
| 4646 | OneOf, |
| 4647 | AnyOf, |
| 4648 | Range, |
| 4649 | Text, |
| 4650 | ] |
| 4651 | assert!; |
| 4652 | |
| 4653 | // Text and Range answer with something that is not one of a set. |
| 4654 | assert!; |
| 4655 | assert!; |
| 4656 | assert!; |
| 4657 | assert!; |
| 4658 | assert!; |
| 4659 | |
| 4660 | |
| 4661 | |
| 4662 | |
| 4663 | // The distinction a bool cannot hold, and the reason Standing has four |
| 4664 | // members: a child under a taken parent narrows the set, and clearing |
| 4665 | // it clears nothing. |
| 4666 | assert!; |
| 4667 | assert!; |
| 4668 | assert!; |
| 4669 | assert!; |
| 4670 | // A prune is a decision that takes the value out. |
| 4671 | assert!; |
| 4672 | assert!; |
| 4673 | assert!; |
| 4674 | assert!; |
| 4675 | // A pruned branch still answers a press, so it may not read as inert. |
| 4676 | assert_ne!; |
| 4677 | |
| 4678 | |
| 4679 | |
| 4680 | |
| 4681 | let inherited = |
| 4682 | of |
| 4683 | .standing |
| 4684 | .at, |
| 4685 | new |
| 4686 | .standing |
| 4687 | .at, |
| 4688 | ]; |
| 4689 | let facet = new; |
| 4690 | assert!; |
| 4691 | // The gutter an indenting renderer reserves before its first paint. |
| 4692 | assert_eq!; |
| 4693 | |
| 4694 | let untouched = |
| 4695 | of.at, |
| 4696 | new |
| 4697 | .standing |
| 4698 | .at, |
| 4699 | ]; |
| 4700 | // Inherited alone is something further up doing the narrowing, and |
| 4701 | // there is nothing further up here. |
| 4702 | assert!; |
| 4703 | |
| 4704 | // A text facet lists nothing, so it is flat and never reads as engaged |
| 4705 | // from its values: the typed string is not held here. |
| 4706 | let typed = new; |
| 4707 | assert!; |
| 4708 | assert_eq!; |
| 4709 | |
| 4710 | |
| 4711 | |
| 4712 | |
| 4713 | // Awaiting::amount's rule in a second place: a written zero reads as |
| 4714 | // "none of them", which is a different claim from "not counted". |
| 4715 | assert_eq!; |
| 4716 | assert_eq!; |
| 4717 | |
| 4718 | |
| 4719 | |
| 4720 | |
| 4721 | assert!; |
| 4722 | for kind in |
| 4723 | Text, |
| 4724 | Textarea, |
| 4725 | Rich, |
| 4726 | Select, |
| 4727 | Checkbox, |
| 4728 | Hidden, |
| 4729 | ] |
| 4730 | assert!; |
| 4731 | |
| 4732 | // The default is a field that takes any one file, which is what an |
| 4733 | // input with no accept and no multiple already is. |
| 4734 | let plain = new; |
| 4735 | assert!; |
| 4736 | assert!; |
| 4737 | |
| 4738 | |
| 4739 | |
| 4740 | |
| 4741 | // The three shapes are the MNW server's own three, and the family is |
| 4742 | // the question a renderer asks before it keeps room for a preview. |
| 4743 | assert_eq! |
| 4744 | Family.family, |
| 4745 | Some |
| 4746 | ; |
| 4747 | assert_eq!; |
| 4748 | assert_eq!; |
| 4749 | assert_eq! |
| 4750 | Type.family, |
| 4751 | Some |
| 4752 | ; |
| 4753 | // A media type outside the three families names none, and neither does |
| 4754 | // a suffix. `.mp3` is audio in fact and this crate will not infer it: |
| 4755 | // the table that said so would rot. |
| 4756 | assert_eq!; |
| 4757 | assert_eq!; |
| 4758 | assert_eq!; |
| 4759 | // Media types are case-insensitive and half the tree writes them |
| 4760 | // lowercase by habit rather than by rule. |
| 4761 | assert_eq!; |
| 4762 | |
| 4763 | |
| 4764 | |
| 4765 | |
| 4766 | assert_eq!; |
| 4767 | assert_eq!; |
| 4768 | assert_eq!; |
| 4769 | assert_eq!; |
| 4770 | assert_eq!; |
| 4771 | |
| 4772 | |
| 4773 | |
| 4774 | |
| 4775 | // The measured dropzone: `accept="image/*,video/*"`. There is no single |
| 4776 | // family to return and there is still a preview to keep room for, which |
| 4777 | // is why the question is asked of the list rather than of one entry. |
| 4778 | const MEDIA: & = & |
| 4779 | Family, |
| 4780 | Family, |
| 4781 | ]; |
| 4782 | assert!; |
| 4783 | // An installer's suffix list wants no disclosure, which is the measured |
| 4784 | // case rather than a hypothetical one. |
| 4785 | const BUILDS: & = &; |
| 4786 | assert!; |
| 4787 | // And a field that takes anything says so by listing nothing. |
| 4788 | assert!; |
| 4789 | |
| 4790 | |
| 4791 | |
| 4792 | |
| 4793 | const IMAGES: & = & |
| 4794 | Type, |
| 4795 | Type, |
| 4796 | Type, |
| 4797 | ]; |
| 4798 | let avatar = upload; |
| 4799 | assert_eq!; |
| 4800 | assert_eq!; |
| 4801 | assert!; |
| 4802 | let several = Field |
| 4803 | multiple: true, |
| 4804 | ..avatar |
| 4805 | ; |
| 4806 | assert!; |
| 4807 | |
| 4808 | |
| 4809 | |
| 4810 | |
| 4811 | // Mutually exclusive is the test for one enum against several fields: a |
| 4812 | // region shows its content, or that it is coming, or that there is none, |
| 4813 | // or that it broke. Never two. |
| 4814 | assert!; |
| 4815 | for state in |
| 4816 | assert!; |
| 4817 | |
| 4818 | |
| 4819 | |
| 4820 | |
| 4821 | |
| 4822 | // The default is the behaviour every region had before this member |
| 4823 | // existed, which is what keeps it additive: a description written |
| 4824 | // against 0.22.0 says the same thing under 0.23.0. |
| 4825 | assert_eq!; |
| 4826 | assert!; |
| 4827 | |
| 4828 | |
| 4829 | |
| 4830 | |
| 4831 | // The two derived idioms differ in one respect and this is it. A |
| 4832 | // carousel's row moves between frames and never reaches empty; a |
| 4833 | // disclosure's summary line is the same control wearing its closed |
| 4834 | // state, so a renderer has to know which it is drawing. |
| 4835 | assert!; |
| 4836 | assert!; |
| 4837 | assert!; |
| 4838 | |
| 4839 | // Both are selective, though. Deriving chrome is one question and |
| 4840 | // whether that chrome closes is another. |
| 4841 | assert!; |
| 4842 | assert!; |
| 4843 | |
| 4844 | |
| 4845 | |
| 4846 | |
| 4847 | // An empty list is the normal state of a new install. Drawing it in a |
| 4848 | // danger tone reports a fault where there is none, and this is the one |
| 4849 | // place the distinction is carried. |
| 4850 | assert_eq!; |
| 4851 | assert_eq!; |
| 4852 | assert_eq!; |
| 4853 | |
| 4854 | |
| 4855 | |
| 4856 | |
| 4857 | // Both combinations mean something, which is why the two fields are |
| 4858 | // independent rather than one implying the other. A list ordered by a |
| 4859 | // key the user cannot change is a real thing with a caret worth drawing. |
| 4860 | let fixed = Column |
| 4861 | sorted: Some, |
| 4862 | ..new |
| 4863 | ; |
| 4864 | |
| 4865 | assert!; |
| 4866 | assert_eq!; |
| 4867 | |
| 4868 | let offered = Column |
| 4869 | sortable: true, |
| 4870 | ..new |
| 4871 | ; |
| 4872 | assert_eq!; |
| 4873 | |
| 4874 | |
| 4875 | |
| 4876 | |
| 4877 | assert_eq!; |
| 4878 | assert_eq!; |
| 4879 | assert_eq!; |
| 4880 | |
| 4881 | |
| 4882 | |
| 4883 | |
| 4884 | // The spelling every renderer reads, so that agreeing is composition |
| 4885 | // rather than three files happening to hold the same literal. |
| 4886 | assert_eq!; |
| 4887 | assert_eq!; |
| 4888 | assert_ne!; |
| 4889 | // Bare. The gap is the renderer's, and a space here would be a second |
| 4890 | // one wherever a renderer already carries its own. |
| 4891 | for d in |
| 4892 | assert_eq!; |
| 4893 | |
| 4894 | |
| 4895 | |
| 4896 | |
| 4897 | |
| 4898 | // Three of goingson's five sites tone the figure by their own means, so |
| 4899 | // tone is carried at every site that needs it and derived at none. The |
| 4900 | // same reasoning `Meter` reached, from a different direction. |
| 4901 | let streak = new.tone; |
| 4902 | assert_eq!; |
| 4903 | assert_eq!; |
| 4904 | |
| 4905 | |
| 4906 | |
| 4907 | |
| 4908 | // 0.13.0. The MNW server's stat card is a label, a value and a delta, |
| 4909 | // across four screens, and the delta is what reads as good or bad. Tone |
| 4910 | // had no consumer before this: the figure itself is an ordinary fact. |
| 4911 | let views = new |
| 4912 | .change |
| 4913 | .tone; |
| 4914 | assert_eq!; |
| 4915 | assert_eq!; |
| 4916 | |
| 4917 | // A figure with nothing to compare against says so by having no change, |
| 4918 | // rather than by carrying an empty string a renderer has to test for. |
| 4919 | assert_eq!; |
| 4920 | |
| 4921 | |
| 4922 | |
| 4923 | |
| 4924 | // "84%", "12/30", "3d". A figure is whatever the app computed, already |
| 4925 | // formatted, and that is the line between this and `Meter`: a meter is |
| 4926 | // a proportion a renderer draws, a figure is a fact it sets in type. |
| 4927 | for value in |
| 4928 | assert_eq!; |
| 4929 | |
| 4930 | |
| 4931 | |
| 4932 | |
| 4933 | |
| 4934 | // The meter carries the tone, so a part-level intent underneath would |
| 4935 | // fight it. Same answer `Tokens` needed, for the same reason. |
| 4936 | assert_eq!; |
| 4937 | |
| 4938 | |
| 4939 | |
| 4940 | |
| 4941 | // It is a control the user operates, unlike `Hidden`, and it does not |
| 4942 | // pick from a list the description carries, unlike `Select`. |
| 4943 | assert!; |
| 4944 | assert!; |
| 4945 | assert!; |
| 4946 | |
| 4947 | |
| 4948 | |
| 4949 | |
| 4950 | // The whole model: the description carries the rule, the renderer emits |
| 4951 | // its host's idiom, and `error` is what arrives back when someone |
| 4952 | // validated. Nothing here decides a value is wrong. |
| 4953 | let field = Field |
| 4954 | max_length: Some, |
| 4955 | min: Some, |
| 4956 | max: Some, |
| 4957 | required: true, |
| 4958 | ..new |
| 4959 | ; |
| 4960 | assert!; |
| 4961 | |
| 4962 | // A bound is text because it is only a number for some of the kinds |
| 4963 | // that take one. goingson has both shapes live. |
| 4964 | let when = Field |
| 4965 | min: Some, |
| 4966 | ..new |
| 4967 | ; |
| 4968 | assert_eq!; |
| 4969 | |
| 4970 | |
| 4971 | |
| 4972 | |
| 4973 | // The whole reason this is a pair. goingson's `Task::time_progress` |
| 4974 | // clamps to 100 and then carries `is_over_estimate` beside it to say |
| 4975 | // what the clamp dropped; a meter says both from one fact. |
| 4976 | let over = new; |
| 4977 | assert_eq!; |
| 4978 | assert!; |
| 4979 | |
| 4980 | let exact = new; |
| 4981 | assert_eq!; |
| 4982 | assert!; |
| 4983 | |
| 4984 | |
| 4985 | |
| 4986 | |
| 4987 | // Sayable on purpose, so it has to be answerable. A meter over an |
| 4988 | // unloaded count is what an app actually has for a frame. |
| 4989 | let none = new; |
| 4990 | assert_eq!; |
| 4991 | assert!; |
| 4992 | assert!; |
| 4993 | |
| 4994 | |
| 4995 | |
| 4996 | |
| 4997 | // Given 43 nothing can recover "3 of 7", which is why the numbers are |
| 4998 | // carried and the label names only the noun. |
| 4999 | let m = new.label; |
| 5000 | assert_eq!; |
| 5001 | assert_eq!; |
| 5002 | assert_eq!; |
| 5003 | |
| 5004 | |
| 5005 | |
| 5006 | |
| 5007 | // The same fullness means opposite things on two of goingson's bars, |
| 5008 | // and only the app knows which. |
| 5009 | let subtasks = new.tone; |
| 5010 | let estimate = new.tone; |
| 5011 | assert_eq!; |
| 5012 | assert_ne!; |
| 5013 | // Untoned by default: a bar says nothing about status until something |
| 5014 | // says so, the same way a row is not selectable until told. |
| 5015 | assert_eq!; |
| 5016 | |
| 5017 | |
| 5018 | |
| 5019 | |
| 5020 | // The one member a renderer must branch on, and since 0.19.0 the only |
| 5021 | // member there is. A stated state is not by itself a reason to stop |
| 5022 | // answering, which is the distinction `State` makes and every |
| 5023 | // hand-rolled button in the tree had to remember. |
| 5024 | assert!; |
| 5025 | assert!; |
| 5026 | |
| 5027 | |
| 5028 | |
| 5029 | |
| 5030 | // No key is the ordinary case, and the webview hosts that ignore it |
| 5031 | // are why it stayed optional. |
| 5032 | assert_eq!; |
| 5033 | let quit = new.key.tone; |
| 5034 | assert_eq!; |
| 5035 | assert_eq!; |
| 5036 | |
| 5037 | |
| 5038 | |
| 5039 | |
| 5040 | // done * 100 in u32 would wrap somewhere past 42 million. Counts that |
| 5041 | // size are not tasks, but a description layer that silently reports 3% |
| 5042 | // for a full bar is worse than one that is slow. |
| 5043 | let big = new; |
| 5044 | assert_eq!; |
| 5045 | assert!; |
| 5046 | |
| 5047 | |
| 5048 | |
| 5049 | |
| 5050 | let = Raised.edges; |
| 5051 | let = Inset.edges; |
| 5052 | assert_eq!; |
| 5053 | assert_eq!; |
| 5054 | |
| 5055 | |
| 5056 | |
| 5057 | |
| 5058 | for b in |
| 5059 | assert_eq!; |
| 5060 | |
| 5061 | |
| 5062 | |
| 5063 | |
| 5064 | |
| 5065 | // The bug this vocabulary exists to make unrepresentable. |
| 5066 | assert_eq!; |
| 5067 | assert_eq!; |
| 5068 | assert_eq!; |
| 5069 | assert_ne!; |
| 5070 | |
| 5071 | |
| 5072 | |
| 5073 | |
| 5074 | // The reason State is its own axis and not a Depth member: a disabled |
| 5075 | // button and a disabled field are both disabled and are not the same |
| 5076 | // shape, which one shared variant could not have said. |
| 5077 | assert_eq!; |
| 5078 | assert_eq!; |
| 5079 | assert!; |
| 5080 | |
| 5081 | |
| 5082 | |
| 5083 | |
| 5084 | // Kept in spirit from the version where `Focus` was the counter-example: |
| 5085 | // suppressing interaction is `Disabled`'s alone, so a member added here |
| 5086 | // later does not get to inherit it by being a state. |
| 5087 | assert!; |
| 5088 | |
| 5089 | |
| 5090 | |
| 5091 | |
| 5092 | // No new token, so this costs no `makeover` release. |
| 5093 | assert_eq!; |
| 5094 | |
| 5095 | |
| 5096 | |
| 5097 | |
| 5098 | assert_eq!; |
| 5099 | assert_eq!; |
| 5100 | |
| 5101 | |
| 5102 | |
| 5103 | |
| 5104 | // The one member carrying a fill without a bevel. A renderer that |
| 5105 | // assumes the two arrive together drops the fill silently, which is |
| 5106 | // exactly what makeover-webview did before 0.3.0. |
| 5107 | assert_eq!; |
| 5108 | assert_eq!; |
| 5109 | |
| 5110 | |
| 5111 | |
| 5112 | |
| 5113 | // Both edgeless, and only one of them needs a colour. Collapsing them |
| 5114 | // is what left an unchosen tab unsayable. |
| 5115 | assert_eq!; |
| 5116 | assert_ne!; |
| 5117 | |
| 5118 | |
| 5119 | |
| 5120 | |
| 5121 | // Authored in opposite directions: makeover derives surface-well by |
| 5122 | // inverting against the theme's content colour, while surface-sunken is |
| 5123 | // authored and may sit darker than raised. |
| 5124 | assert_ne!; |
| 5125 | assert_eq!; |
| 5126 | assert_eq!; |
| 5127 | |
| 5128 | |
| 5129 | |
| 5130 | |
| 5131 | // The gap 0.3.0 closed. Before it, only `chosen` existed and the |
| 5132 | // unchosen option fell through to Flat at every renderer. |
| 5133 | for s in |
| 5134 | assert_ne! |
| 5135 | s.chosen, |
| 5136 | s.unchosen, |
| 5137 | "{s:?} cannot tell picked from unpicked" |
| 5138 | ; |
| 5139 | |
| 5140 | |
| 5141 | |
| 5142 | |
| 5143 | |
| 5144 | // Tabs recede so the chosen one comes forward; a segment and a toggle |
| 5145 | // stand up so the chosen one is held in. That inversion is the whole |
| 5146 | // content of "picked" once colour is deferred, and it is why the three |
| 5147 | // are not one member with a flag. |
| 5148 | assert_eq!; |
| 5149 | assert_eq!; |
| 5150 | |
| 5151 | for s in |
| 5152 | assert_eq!; |
| 5153 | assert_eq!; |
| 5154 | // Held in is what pressing produces: one appearance, two reasons. |
| 5155 | assert_eq!; |
| 5156 | |
| 5157 | |
| 5158 | |
| 5159 | |
| 5160 | |
| 5161 | assert_eq!; |
| 5162 | assert_eq! |
| 5163 | Raised.pressed.bevel, |
| 5164 | Raised.bevel.map |
| 5165 | ; |
| 5166 | // Only raised regions respond to being pressed. |
| 5167 | assert_eq!; |
| 5168 | assert_eq!; |
| 5169 | // An overlay is a surface, not a control. |
| 5170 | assert_eq!; |
| 5171 | |
| 5172 | |
| 5173 | |
| 5174 | |
| 5175 | // The wave-2 rule: a surface over the page takes elevation, a surface |
| 5176 | // in the page takes a bevel. Both halves come off the one Depth, so |
| 5177 | // they cannot disagree. |
| 5178 | assert_eq!; |
| 5179 | assert_eq!; |
| 5180 | |
| 5181 | // Three depths have no bevel and they are not the same claim. Flat has |
| 5182 | // nothing to separate from, Sunken's colour is doing the separating, |
| 5183 | // and an overlay is separated by the lift. |
| 5184 | assert_ne!; |
| 5185 | assert_ne!; |
| 5186 | |
| 5187 | |
| 5188 | |
| 5189 | |
| 5190 | assert_eq!; |
| 5191 | assert_eq!; |
| 5192 | assert_eq!; |
| 5193 | assert_eq!; |
| 5194 | // No value ever leaves this crate. |
| 5195 | for t in |
| 5196 | Light.token, |
| 5197 | Dark.token, |
| 5198 | Danger.token, |
| 5199 | Neutral.token, |
| 5200 | Disabled.token, |
| 5201 | ] |
| 5202 | assert!; |
| 5203 | assert! |
| 5204 | !t.chars.next.unwrap.is_ascii_digit, |
| 5205 | "{t} is a value" |
| 5206 | ; |
| 5207 | |
| 5208 | |
| 5209 | |
| 5210 | |
| 5211 | |
| 5212 | // The one line that runs through all three apps' taxonomies. |
| 5213 | assert!; |
| 5214 | assert!; |
| 5215 | assert!; |
| 5216 | |
| 5217 | // A badge is a label, so giving it an edge would lie about it. |
| 5218 | assert_eq!; |
| 5219 | assert_eq!; |
| 5220 | |
| 5221 | // A latched chip wears the same shape a pressed one does. |
| 5222 | let chip = Chip ; |
| 5223 | assert_eq!; |
| 5224 | assert_eq!; |
| 5225 | |
| 5226 | |
| 5227 | |
| 5228 | |
| 5229 | assert!; |
| 5230 | assert!; |
| 5231 | // A toast floats above the page; a banner rests in the flow. |
| 5232 | assert_eq!; |
| 5233 | assert_eq!; |
| 5234 | |
| 5235 | |
| 5236 | |
| 5237 | |
| 5238 | // `revealed_on_hover` was asserted here until 0.13.0 retired it. It said |
| 5239 | // a row's actions stay hidden until hover, which stopped being true when |
| 5240 | // makeover-webview 0.23.0 showed them at rest, and nothing had consumed |
| 5241 | // it for a release either way. |
| 5242 | assert_eq!; |
| 5243 | assert_eq!; |
| 5244 | assert_eq!; |
| 5245 | |
| 5246 | |
| 5247 | |
| 5248 | |
| 5249 | // Each token carries its own tone, so a part-level intent underneath |
| 5250 | // would fight the thing sitting on it. Same reasoning as actions, which |
| 5251 | // is why they answer alike. |
| 5252 | assert_eq!; |
| 5253 | assert_eq!; |
| 5254 | |
| 5255 | |
| 5256 | |
| 5257 | |
| 5258 | // The pair is named once so a host with parsing to do asks here rather |
| 5259 | // than spelling it out, which is `offers_options`' reason. |
| 5260 | assert!; |
| 5261 | assert!; |
| 5262 | |
| 5263 | for kind in |
| 5264 | Text, |
| 5265 | Secret, |
| 5266 | Number, |
| 5267 | Email, |
| 5268 | Url, |
| 5269 | Tel, |
| 5270 | Range, |
| 5271 | Textarea, |
| 5272 | Rich, |
| 5273 | Select, |
| 5274 | Radio, |
| 5275 | Checkbox, |
| 5276 | File, |
| 5277 | Hidden, |
| 5278 | ] |
| 5279 | assert!; |
| 5280 | |
| 5281 | |
| 5282 | |
| 5283 | |
| 5284 | |
| 5285 | // The formats are the whole reason the members are worth naming apart |
| 5286 | // from text, so the doc comments and the constants have to agree. A |
| 5287 | // host reading one and meeting the other is the silent failure. |
| 5288 | assert_eq!; |
| 5289 | assert!; |
| 5290 | |
| 5291 | assert_eq!; |
| 5292 | assert! |
| 5293 | DATETIME_FORMAT.starts_with, |
| 5294 | "a moment starts with the day it is on" |
| 5295 | ; |
| 5296 | // Local, and that is a property of the value rather than an omission. |
| 5297 | assert!; |
| 5298 | assert!; |
| 5299 | assert!; |
| 5300 | |
| 5301 | |
| 5302 | |
| 5303 | |
| 5304 | // Neither is a checkbox and neither is a fixed set, so both fall where |
| 5305 | // text does. Asserted because a new kind lands in three predicates and |
| 5306 | // only one of them is the interesting one. |
| 5307 | for kind in |
| 5308 | assert!; |
| 5309 | assert!; |
| 5310 | assert!; |
| 5311 | assert!; |
| 5312 | |
| 5313 | |
| 5314 | |
| 5315 | |
| 5316 | |
| 5317 | // The table half of what RowPart::intent does for rows. A cell holding |
| 5318 | // a control and a cell holding text answered alike until 0.14.0, and a |
| 5319 | // control in a cell took the cell's text colour. |
| 5320 | assert_eq!; |
| 5321 | |
| 5322 | for part in |
| 5323 | // Each for its own reason -- a token carries its tone, an action is |
| 5324 | // a control, a link takes the action colour -- and all three reach |
| 5325 | // the intent inheriting already gives. |
| 5326 | assert_eq!; |
| 5327 | |
| 5328 | |
| 5329 | |
| 5330 | |
| 5331 | |
| 5332 | for part in |
| 5333 | Value, |
| 5334 | Tokens, |
| 5335 | Actions, |
| 5336 | Link, |
| 5337 | ] |
| 5338 | let intent = part.intent; |
| 5339 | assert!; |
| 5340 | assert!; |
| 5341 | |
| 5342 | |
| 5343 | |
| 5344 | |
| 5345 | |
| 5346 | assert!; |
| 5347 | assert!; |
| 5348 | assert!; |
| 5349 | |
| 5350 | |
| 5351 | |
| 5352 | |
| 5353 | assert_eq!; |
| 5354 | assert_eq!; |
| 5355 | // The exception, and the whole folder semantic: the open tab joins its |
| 5356 | // pane rather than sinking away from it. |
| 5357 | assert_eq!; |
| 5358 | |
| 5359 | // A held-in segment is indistinguishable from a pressed raised one, |
| 5360 | // which is the economy the light model buys over a colour swap. |
| 5361 | assert_eq!; |
| 5362 | |
| 5363 | // A toggle stands alone; the other two are built out of parts that |
| 5364 | // touch. |
| 5365 | assert!; |
| 5366 | assert!; |
| 5367 | assert!; |
| 5368 | |
| 5369 | |
| 5370 | |
| 5371 | |
| 5372 | // The distinction the member exists for. A split's two panes stand in a |
| 5373 | // master-detail relationship; columns choose nothing about each other. |
| 5374 | // Both are flat, so depth cannot tell them apart and the doc has to. |
| 5375 | assert_eq!; |
| 5376 | assert_eq!; |
| 5377 | assert_ne!; |
| 5378 | |
| 5379 | |
| 5380 | |
| 5381 | |
| 5382 | // The two things a board is always asked to carry and must not. How |
| 5383 | // many is what the children say; how wide is settled by "peers are |
| 5384 | // equal". |
| 5385 | // |
| 5386 | // The guard is the binding itself and it is a compile-time one: adding |
| 5387 | // a field to `Columns` stops this line compiling, which is a better |
| 5388 | // failure than any assertion about it. Written out rather than inlined |
| 5389 | // for exactly that reason. |
| 5390 | let columns: = Columns; |
| 5391 | assert_eq!; |
| 5392 | |
| 5393 | |
| 5394 | |
| 5395 | |
| 5396 | // A board's contents are ordinary description all the way down, so a |
| 5397 | // renderer that does not lay them across still draws every column. |
| 5398 | // Stacking them vertically is honouring this member, not degrading it. |
| 5399 | assert!; |
| 5400 | assert!; |
| 5401 | |
| 5402 | |
| 5403 | |
| 5404 | |
| 5405 | // Every renderer divides by this. A caller passing a backwards or empty |
| 5406 | // span is a bug, but it is not a bug worth a panic three renderers deep. |
| 5407 | assert_eq!; |
| 5408 | assert_eq!; |
| 5409 | assert_eq!; |
| 5410 | |
| 5411 | |
| 5412 | |
| 5413 | |
| 5414 | // 22:00 to 02:00. The alternative was carrying a date, which drags a |
| 5415 | // timezone into the vocabulary for the sake of one night shift. |
| 5416 | let overnight = new; |
| 5417 | assert_eq!; |
| 5418 | assert!; |
| 5419 | assert!; |
| 5420 | |
| 5421 | |
| 5422 | |
| 5423 | |
| 5424 | // The reason Placement carries no `conflicts` flag: the times already |
| 5425 | // say it, and a second source for one fact is how a stale conflict |
| 5426 | // badge outlives the conflict. |
| 5427 | let morning = new; // 09:00-10:00 |
| 5428 | let overlapping = new; // 09:30-10:30 |
| 5429 | let after = new; // 10:00-11:00 |
| 5430 | |
| 5431 | assert!; |
| 5432 | assert!; |
| 5433 | // Touching end to end is not overlapping: `to` is exclusive, so a |
| 5434 | // 10:00 start does not collide with a 10:00 end. |
| 5435 | assert!; |
| 5436 | assert!; |
| 5437 | |
| 5438 | |
| 5439 | |
| 5440 | |
| 5441 | assert_eq!; |
| 5442 | assert_eq!; |
| 5443 | |
| 5444 | |
| 5445 | |
| 5446 | |
| 5447 | let day = DAY; |
| 5448 | assert!; |
| 5449 | assert!; |
| 5450 | // Clamped rather than off the end: an event running past the span's |
| 5451 | // close draws at the edge, which beats panicking or drawing nowhere. |
| 5452 | assert!; |
| 5453 | |
| 5454 | |
| 5455 | |
| 5456 | |
| 5457 | assert_eq!; |
| 5458 | assert_eq!; |
| 5459 | // A span that does not divide evenly keeps a slot for its tail. |
| 5460 | assert_eq!; |
| 5461 | // slot: 0 is a caller bug that reads as one slot, not a panic. |
| 5462 | let degenerate = Track |
| 5463 | span: DAY, |
| 5464 | slot: 0, |
| 5465 | tick: 60, |
| 5466 | unit: Minutes, |
| 5467 | ; |
| 5468 | assert_eq!; |
| 5469 | |
| 5470 | |
| 5471 | |
| 5472 | |
| 5473 | // The guard on the thing the withdrawn refusal was right about. If a |
| 5474 | // pixel measure, a scroll offset or a colour ever lands on Track, the |
| 5475 | // member has stopped being a fact about the data and the timeline |
| 5476 | // really has become a component library wearing a description's name. |
| 5477 | let day = DAY; |
| 5478 | assert_eq!; |
| 5479 | assert_eq!; |
| 5480 | assert_eq!; |
| 5481 | assert_eq!; |
| 5482 | |
| 5483 | // Three fields when this was written, and the fourth came here to say |
| 5484 | // why, which is the whole point of the assertion. `unit` is what the |
| 5485 | // integers COUNT -- a fact about the data, unavailable from the numbers |
| 5486 | // themselves, and the absence of it is what let a month strip render |
| 5487 | // under a wall clock. A fifth field still has to argue, and "the |
| 5488 | // renderer would find it handy" is still not the argument. |
| 5489 | // Destructured rather than rebuilt: this is the form that names every |
| 5490 | // field and stops compiling when a fifth arrives, without binding |
| 5491 | // anything a lint has to forgive. |
| 5492 | let Track |
| 5493 | span: _, |
| 5494 | slot: _, |
| 5495 | tick: _, |
| 5496 | unit: _, |
| 5497 | = day; |
| 5498 | |
| 5499 | |
| 5500 | |
| 5501 | |
| 5502 | // The probe that found the defect, kept as a test. Fifteen days from |
| 5503 | // day three, on a thirty-one day month: the geometry was always right |
| 5504 | // and only the label was wrong, which is why `unit` is a fact and not |
| 5505 | // presentation. |
| 5506 | let march = days; |
| 5507 | assert_eq!; |
| 5508 | assert_eq!; |
| 5509 | |
| 5510 | let leave = new; |
| 5511 | assert!; |
| 5512 | assert!; |
| 5513 | |
| 5514 | |
| 5515 | |
| 5516 | |
| 5517 | assert_eq!; |
| 5518 | assert_eq!; |
| 5519 | for r in |
| 5520 | Band, |
| 5521 | Sidebar, |
| 5522 | Group, |
| 5523 | Split, |
| 5524 | TabGroup, |
| 5525 | ] |
| 5526 | assert_eq!; |
| 5527 | |
| 5528 | |
| 5529 | |
| 5530 | |
| 5531 | |
| 5532 | // The escape hatch is one member and stays one member. If a second |
| 5533 | // undescribed region ever appears, the description has started |
| 5534 | // conceding rather than deferring. |
| 5535 | for r in |
| 5536 | Band, |
| 5537 | Sidebar, |
| 5538 | Pane, |
| 5539 | Group, |
| 5540 | Split, |
| 5541 | TabGroup, |
| 5542 | Modal, |
| 5543 | // A widget is described, and that is the whole of what separates it |
| 5544 | // from a bespoke here. Both carry a name this crate never reads; |
| 5545 | // only one of them has contents under it that a renderer which does |
| 5546 | // not know the name can still walk. |
| 5547 | Widget , |
| 5548 | ] |
| 5549 | assert!; |
| 5550 | |
| 5551 | assert!; |
| 5552 | |
| 5553 | |
| 5554 | |
| 5555 | |
| 5556 | // The distinction a renderer with no graphics protocol runs on: draw |
| 5557 | // the words, or draw nothing. Standing in for a decorative rule with |
| 5558 | // the word "decoration" is worse than leaving the space empty. |
| 5559 | assert!; |
| 5560 | assert!; |
| 5561 | |
| 5562 | |
| 5563 | |
| 5564 | |
| 5565 | // A caption is content everybody reads; alt text stands in for the |
| 5566 | // picture. A screenshot with a caption still needs alt text. |
| 5567 | let shot = new.caption; |
| 5568 | assert_eq!; |
| 5569 | assert!; |
| 5570 | assert_ne!; |
| 5571 | |
| 5572 | |
| 5573 | |
| 5574 | |
| 5575 | // The whole point: a renderer reserves from the ratio, so the space is |
| 5576 | // right at any width. A fixed height would only be right at one. |
| 5577 | let shot = new.intrinsic; |
| 5578 | let e = shot.intrinsic.expect; |
| 5579 | assert_eq!; |
| 5580 | assert!; |
| 5581 | |
| 5582 | |
| 5583 | |
| 5584 | |
| 5585 | // `None` is honest: a creator upload whose size was never recorded does |
| 5586 | // not know it. A renderer must not invent one. |
| 5587 | assert_eq!; |
| 5588 | assert_eq!; |
| 5589 | assert_eq!; |
| 5590 | |
| 5591 | |
| 5592 | |
| 5593 | |
| 5594 | // Eager is the safe default and lazy is the opt-in, because deferring |
| 5595 | // something already on screen saves nothing and moves its shift later. |
| 5596 | assert_eq!; |
| 5597 | assert_eq!; |
| 5598 | assert_eq!; |
| 5599 | |
| 5600 | |
| 5601 | |
| 5602 | |
| 5603 | // The default is the one that shows the whole picture at its own shape, |
| 5604 | // so a renderer ignoring Fit entirely is still right about the common |
| 5605 | // case. The shipped MNW carousel sets no object-fit at all, which is |
| 5606 | // this. |
| 5607 | assert_eq!; |
| 5608 | assert_eq!; |
| 5609 | assert_eq!; |
| 5610 | |
| 5611 | |
| 5612 | |
| 5613 | |
| 5614 | // The whole of why this is a member rather than a `Pane`. A pane is |
| 5615 | // looked into and scrolls; a group is neither, and four groups inside a |
| 5616 | // settings pane described as panes are four wells inside a well. |
| 5617 | assert_eq!; |
| 5618 | assert_eq!; |
| 5619 | assert_ne!; |
| 5620 | |
| 5621 | // Described, and it carries no name: a group is a primitive every |
| 5622 | // renderer draws from scratch, which is what separates it from the two |
| 5623 | // members that do carry one. |
| 5624 | assert!; |
| 5625 | assert_eq!; |
| 5626 | |
| 5627 | |
| 5628 | |
| 5629 | |
| 5630 | // `Heading::Section` has said "names a block within the screen" since |
| 5631 | // 0.2.0 and there was no block. The pairing is the point, and it is the |
| 5632 | // reason a group carries no heading of its own: the heading is an |
| 5633 | // ordinary node in the body, and a group without one is legal. |
| 5634 | assert!; |
| 5635 | assert_eq!; |
| 5636 | |
| 5637 | |
| 5638 | |
| 5639 | |
| 5640 | // Stronger than the bespoke case: a widget is drawn by whichever |
| 5641 | // renderer recognises the name, so a depth chosen here would be this |
| 5642 | // crate deciding a carousel is raised on every host. |
| 5643 | assert_eq!; |
| 5644 | assert_eq!; |
| 5645 | |
| 5646 | |
| 5647 | |
| 5648 | |
| 5649 | // A renderer dispatching on a name wants the string, not the member. |
| 5650 | // Writing that `matches!` at each renderer is how the two drift apart. |
| 5651 | assert_eq!; |
| 5652 | assert_eq! |
| 5653 | Bespoke .name, |
| 5654 | Some |
| 5655 | ; |
| 5656 | |
| 5657 | for r in |
| 5658 | Band, |
| 5659 | Sidebar, |
| 5660 | Pane, |
| 5661 | Group, |
| 5662 | Split, |
| 5663 | TabGroup, |
| 5664 | Modal, |
| 5665 | ] |
| 5666 | assert_eq!; |
| 5667 | |
| 5668 | |
| 5669 | |
| 5670 | |
| 5671 | |
| 5672 | // The app owns the contents, not the placement. An app that wants its |
| 5673 | // timeline in a well frames it in a Pane. |
| 5674 | assert_eq!; |
| 5675 | assert_eq!; |
| 5676 | |
| 5677 | |
| 5678 | |
| 5679 | |
| 5680 | // The argument the member exists for: goingson's day-plan has to be |
| 5681 | // routable, or the description covers only the boring screens and the |
| 5682 | // interesting four need a second path beside the router. |
| 5683 | let day_plan = |
| 5684 | Band, |
| 5685 | Bespoke , |
| 5686 | Sidebar, |
| 5687 | ]; |
| 5688 | assert_eq!; |
| 5689 | assert_eq!; |
| 5690 | |
| 5691 | |
| 5692 | |
| 5693 | |
| 5694 | let secret = new; |
| 5695 | assert!; |
| 5696 | assert!; |
| 5697 | |
| 5698 | assert!; |
| 5699 | // Nothing else is confidential, or the marker means nothing. |
| 5700 | for k in |
| 5701 | Text, |
| 5702 | Number, |
| 5703 | Textarea, |
| 5704 | Rich, |
| 5705 | Select, |
| 5706 | Checkbox, |
| 5707 | Hidden, |
| 5708 | ] |
| 5709 | assert!; |
| 5710 | |
| 5711 | |
| 5712 | // Only a checkbox carries its own label. |
| 5713 | assert!; |
| 5714 | assert!; |
| 5715 | |
| 5716 | |
| 5717 | |
| 5718 | |
| 5719 | let text = new; |
| 5720 | assert!; |
| 5721 | assert_eq!; |
| 5722 | |
| 5723 | let sizes = ; |
| 5724 | let select = select; |
| 5725 | assert_eq!; |
| 5726 | assert_eq!; |
| 5727 | |
| 5728 | |
| 5729 | |
| 5730 | |
| 5731 | // The whole reason it is two strings. `plain` is the case where they |
| 5732 | // coincide, and it is a shorthand rather than the general shape. |
| 5733 | let plain = plain; |
| 5734 | assert_eq!; |
| 5735 | |
| 5736 | let spelled = new; |
| 5737 | assert_ne!; |
| 5738 | assert! |
| 5739 | spelled.available, |
| 5740 | "an option is pickable until it says not" |
| 5741 | ; |
| 5742 | |
| 5743 | |
| 5744 | |
| 5745 | |
| 5746 | // Both offer a fixed set and both read `options`, so the two |
| 5747 | // constructors differ in exactly one thing. That one thing is the |
| 5748 | // point: a renderer decides whether the alternatives are readable |
| 5749 | // without opening anything, and it can only decide that if the |
| 5750 | // description said which question was asked. |
| 5751 | let styles = |
| 5752 | new, |
| 5753 | new, |
| 5754 | ]; |
| 5755 | let radio = radio; |
| 5756 | let select = select; |
| 5757 | |
| 5758 | assert_eq!; |
| 5759 | assert_ne!; |
| 5760 | assert_eq!; |
| 5761 | assert_eq! |
| 5762 | Field |
| 5763 | kind: select.kind, |
| 5764 | ..radio |
| 5765 | , |
| 5766 | select |
| 5767 | ; |
| 5768 | |
| 5769 | |
| 5770 | |
| 5771 | |
| 5772 | // The whole content of the one-member shape: saying an option is not |
| 5773 | // pickable and saying why are the same act, so the greyed-out-with-no- |
| 5774 | // reason state is unsayable rather than merely discouraged. |
| 5775 | let multi = |
| 5776 | new.unless; |
| 5777 | assert!; |
| 5778 | assert_eq! |
| 5779 | multi.unavailable, |
| 5780 | Some |
| 5781 | ; |
| 5782 | |
| 5783 | // And the option is still in the list, carrying what it submits, so a |
| 5784 | // renderer draws it rather than the app dropping it. |
| 5785 | assert_eq!; |
| 5786 | assert_eq!; |
| 5787 | |
| 5788 | |
| 5789 | |
| 5790 | |
| 5791 | // The distinction the kind exists for, asserted rather than only |
| 5792 | // written down: bounds are a rule for one and the control itself for |
| 5793 | // the other. |
| 5794 | let threshold = range; |
| 5795 | assert_eq!; |
| 5796 | assert!; |
| 5797 | assert_eq!; |
| 5798 | assert_eq!; |
| 5799 | // Granularity is the host's until an app says otherwise. |
| 5800 | assert_eq!; |
| 5801 | |
| 5802 | // goingson's duration: a typed number with a floor, and it must not |
| 5803 | // read as a slider. |
| 5804 | let minutes = Field |
| 5805 | min: Some, |
| 5806 | ..new |
| 5807 | ; |
| 5808 | assert_ne!; |
| 5809 | assert!; |
| 5810 | |
| 5811 | |
| 5812 | |
| 5813 | |
| 5814 | // Nothing here enforces the pair, for the reason nothing here enforces |
| 5815 | // `required`: the description states the constraint and the renderer |
| 5816 | // asks. What it must not do is look bounded. |
| 5817 | let half = Field |
| 5818 | max: Some, |
| 5819 | ..new |
| 5820 | ; |
| 5821 | assert!; |
| 5822 | |
| 5823 | |
| 5824 | |
| 5825 | |
| 5826 | // The renderers branch on this rather than on a list of their own, so |
| 5827 | // a kind added without a decision here renders its options nowhere. |
| 5828 | assert!; |
| 5829 | assert!; |
| 5830 | for kind in |
| 5831 | Text, |
| 5832 | Secret, |
| 5833 | Number, |
| 5834 | Email, |
| 5835 | Url, |
| 5836 | Tel, |
| 5837 | Range, |
| 5838 | Textarea, |
| 5839 | Rich, |
| 5840 | Checkbox, |
| 5841 | Hidden, |
| 5842 | ] |
| 5843 | assert!; |
| 5844 | |
| 5845 | |
| 5846 | |
| 5847 | |
| 5848 | |
| 5849 | // The near-miss: each option is labelled beside its own button, so a |
| 5850 | // renderer could plausibly read the group as self-labelling and drop |
| 5851 | // the question. Checkbox is the only kind that does that. |
| 5852 | assert!; |
| 5853 | assert!; |
| 5854 | |
| 5855 | |
| 5856 | |
| 5857 | |
| 5858 | // An app whose option list has not loaded has exactly this. Making it |
| 5859 | // unrepresentable would push the state somewhere less visible, and a |
| 5860 | // renderer drawing an empty select reports it on screen. |
| 5861 | let loading = select; |
| 5862 | assert!; |
| 5863 | |
| 5864 | |
| 5865 | |
| 5866 | |
| 5867 | // The line 0.8.0 drew. Placeholder and options are properties of what |
| 5868 | // is being asked; the current value is what came back, and no field |
| 5869 | // here holds one. |
| 5870 | let f = Field |
| 5871 | placeholder: Some, |
| 5872 | ..new |
| 5873 | ; |
| 5874 | assert_eq!; |
| 5875 | // A placeholder is not a label, and having one does not excuse the |
| 5876 | // field from carrying the other. |
| 5877 | assert_eq!; |
| 5878 | |
| 5879 | |
| 5880 | |
| 5881 | |
| 5882 | let mut f = new; |
| 5883 | assert!; |
| 5884 | f.error = Some; |
| 5885 | assert!; |
| 5886 | |
| 5887 | |
| 5888 | |
| 5889 | |
| 5890 | let cols = |
| 5891 | Column |
| 5892 | width: Fill, |
| 5893 | priority: Essential, |
| 5894 | ..new |
| 5895 | , |
| 5896 | Column |
| 5897 | width: Fixed, |
| 5898 | priority: Secondary, |
| 5899 | ..new |
| 5900 | , |
| 5901 | Column |
| 5902 | width: Fixed, |
| 5903 | priority: Optional, |
| 5904 | ..new |
| 5905 | , |
| 5906 | ]; |
| 5907 | |
| 5908 | // Widest: everything survives. |
| 5909 | assert_eq! |
| 5910 | cols.iter |
| 5911 | .filter |
| 5912 | .count, |
| 5913 | 3 |
| 5914 | ; |
| 5915 | // Narrower: the optional column goes first. |
| 5916 | let kept: = cols |
| 5917 | .iter |
| 5918 | .filter |
| 5919 | .map |
| 5920 | .collect; |
| 5921 | assert_eq!; |
| 5922 | // Narrowest: only what identifies the row. |
| 5923 | let kept: = cols |
| 5924 | .iter |
| 5925 | .filter |
| 5926 | .map |
| 5927 | .collect; |
| 5928 | assert_eq!; |
| 5929 | |
| 5930 | |
| 5931 | |
| 5932 | |
| 5933 | // The bug the ordinal form has and this form cannot: goingson hides |
| 5934 | // `nth-child(n+5)` against a seven-column table, so a column inserted |
| 5935 | // anywhere to the left silently hides a different one. |
| 5936 | let before = |
| 5937 | new, |
| 5938 | Column |
| 5939 | width: Fixed, |
| 5940 | priority: Optional, |
| 5941 | ..new |
| 5942 | , |
| 5943 | ]; |
| 5944 | let after = |
| 5945 | new, |
| 5946 | new, // inserted |
| 5947 | Column |
| 5948 | width: Fixed, |
| 5949 | priority: Optional, |
| 5950 | ..new |
| 5951 | , |
| 5952 | ]; |
| 5953 | |
| 5954 | |
| 5955 | cols.iter |
| 5956 | .filter |
| 5957 | .map |
| 5958 | .collect |
| 5959 | |
| 5960 | assert_eq!; |
| 5961 | assert_eq!; |
| 5962 | |
| 5963 | |
| 5964 | |
| 5965 | |
| 5966 | // goingson uses the tab group inside the content region rather than |
| 5967 | // instead of one, so it is not a third arrangement. |
| 5968 | let go = list_detail; |
| 5969 | let plain = list_detail; |
| 5970 | assert_ne!; |
| 5971 | assert_ne!; |
| 5972 | |
| 5973 | |
| 5974 | |
| 5975 | |
| 5976 | // The point of the member: a terminal reading columns and a webview |
| 5977 | // reading a grid honour one fact, so two hosts showing one screen agree |
| 5978 | // about its proportions. |
| 5979 | assert_eq!; |
| 5980 | assert_eq!; |
| 5981 | assert_eq! |
| 5982 | SIDEBAR.of, |
| 5983 | 24, |
| 5984 | "quasi-tui's 24 columns, said as a quarter" |
| 5985 | ; |
| 5986 | |
| 5987 | |
| 5988 | |
| 5989 | |
| 5990 | // A region the description named should be visible. A zero-width one |
| 5991 | // reads on screen as a region that vanished, which is the hardest kind |
| 5992 | // of bug to find from what is drawn. |
| 5993 | assert_eq!; |
| 5994 | assert_eq!; |
| 5995 | |
| 5996 | |
| 5997 | |
| 5998 | |
| 5999 | assert_eq!; |
| 6000 | assert_eq!; |
| 6001 | |
| 6002 | |
| 6003 | |
| 6004 | |
| 6005 | // How much a sidebar takes and how much a list side takes are different |
| 6006 | // questions, and this enum is the only thing that knows which is being |
| 6007 | // asked. |
| 6008 | assert_eq!; |
| 6009 | assert_eq!; |
| 6010 | |
| 6011 | let narrow = sidebar_content.with_share; |
| 6012 | assert_eq!; |
| 6013 | assert!; |
| 6014 | |
| 6015 | |
| 6016 | |
| 6017 | |
| 6018 | // The default is meaningful: a screen nobody said anything about uses |
| 6019 | // the window it was given. |
| 6020 | assert_eq!; |
| 6021 | assert_eq!; |
| 6022 | |
| 6023 | |
| 6024 | |
| 6025 | |
| 6026 | // Two members and no third. If a skeleton ever appears in this enum, |
| 6027 | // the deferral rule has been broken. |
| 6028 | assert_ne!; |
| 6029 | |
| 6030 | |
| 6031 | |
| 6032 | |
| 6033 | // The uncounted case is the common one, not the degenerate one: a query |
| 6034 | // that asked for 51 to learn there were more than 50 knows there are, |
| 6035 | // and not how many. |
| 6036 | let uncounted = new; |
| 6037 | assert_eq!; |
| 6038 | assert_eq!; |
| 6039 | assert!; |
| 6040 | // Unknown length cannot rule out more, and offering a way forward that |
| 6041 | // turns out empty is the cheaper mistake. |
| 6042 | assert!; |
| 6043 | |
| 6044 | |
| 6045 | |
| 6046 | |
| 6047 | let last = new.of; |
| 6048 | assert_eq!; |
| 6049 | assert_eq!; |
| 6050 | assert!; |
| 6051 | assert!; |
| 6052 | |
| 6053 | let first = new.of; |
| 6054 | assert!; |
| 6055 | assert!; |
| 6056 | |
| 6057 | |
| 6058 | |
| 6059 | |
| 6060 | // 401 rows in pages of 50 is eight pages and a straggler, which is nine |
| 6061 | // pages. Rounding down would make the last one unreachable. |
| 6062 | assert_eq!; |
| 6063 | |
| 6064 | |
| 6065 | |
| 6066 | |
| 6067 | let empty = new.of; |
| 6068 | assert_eq!; |
| 6069 | assert_eq!; |
| 6070 | // And it still clamps rather than panicking. |
| 6071 | assert_eq!; |
| 6072 | |
| 6073 | |
| 6074 | |
| 6075 | |
| 6076 | // `Slot::current`'s reasoning, one layer down: a description pointing |
| 6077 | // past the end is a host bug, and answering it by drawing nothing |
| 6078 | // reports a region that vanished. |
| 6079 | assert_eq!; |
| 6080 | // Nothing to clamp against when the length is unknown. |
| 6081 | assert_eq!; |
| 6082 | |
| 6083 | |
| 6084 | |
| 6085 | |
| 6086 | // The shape a carousel instantiates. Same code as a paged list, which is |
| 6087 | // the whole reason `Window` exists rather than two copies of it. |
| 6088 | let third = frame; |
| 6089 | assert_eq!; |
| 6090 | assert_eq!; |
| 6091 | assert!; |
| 6092 | assert!; |
| 6093 | |
| 6094 | let last = frame; |
| 6095 | assert!; |
| 6096 | |
| 6097 | |
| 6098 | |
| 6099 | |
| 6100 | // The page number is read aloud, so it is one-based; `Window::index` is |
| 6101 | // the zero-based form for indexing. |
| 6102 | let third = pages.of; |
| 6103 | assert_eq!; |
| 6104 | assert_eq!; |
| 6105 | assert_eq!; |
| 6106 | assert!; |
| 6107 | assert!; |
| 6108 | |
| 6109 | // Load-more grew a window from the start, so "page 2" would name |
| 6110 | // nothing and the type says so rather than inventing one. |
| 6111 | let grown = more.of; |
| 6112 | assert_eq!; |
| 6113 | assert_eq!; |
| 6114 | assert_eq!; |
| 6115 | assert!; |
| 6116 | assert!; |
| 6117 | |
| 6118 | |
| 6119 | |
| 6120 | |
| 6121 | // What a host that will not pay for a COUNT describes. `None` here is |
| 6122 | // permanent: a total arriving later would widen the text that prints it, |
| 6123 | // which is the reflow "first paint is final paint" forbids. |
| 6124 | let feed = more; |
| 6125 | assert_eq!; |
| 6126 | assert_eq!; |
| 6127 | assert_eq!; |
| 6128 | assert!; |
| 6129 | |
| 6130 | |
| 6131 | |
| 6132 | |
| 6133 | assert_eq!; |
| 6134 | assert_eq!; |
| 6135 | // A host that overshot its own total gets zero rather than a wrapped |
| 6136 | // usize, which would print as "18446744073709551516 remaining". |
| 6137 | assert_eq!; |
| 6138 | |
| 6139 | |
| 6140 | |
| 6141 | |
| 6142 | // The case the type exists for: 913px is a roomy window holding a group |
| 6143 | // that has run out of room, so room is measured against the group's own |
| 6144 | // allocation and never against the viewport. |
| 6145 | assert!; |
| 6146 | // A group nesting another has whichever room is scarcer, which is what |
| 6147 | // makes relief resolve inside-out rather than by declaration order. |
| 6148 | assert_eq!; |
| 6149 | |
| 6150 | |
| 6151 | |
| 6152 | |
| 6153 | // No `Default`. The compiler is what enforces rule 2, so the assertion |
| 6154 | // that matters is one this file cannot write; what it can say is that |
| 6155 | // the four authored answers are distinct and none is privileged. |
| 6156 | let all = |
| 6157 | Wrap, |
| 6158 | Stack, |
| 6159 | Shed, |
| 6160 | Menu, |
| 6161 | ]; |
| 6162 | for in all.iter.enumerate |
| 6163 | for b in &all |
| 6164 | assert_ne!; |
| 6165 | |
| 6166 | |
| 6167 | |
| 6168 | |
| 6169 | |
| 6170 | |
| 6171 | // Priority is read the same way for a group member as for a column, |
| 6172 | // which is the whole claim of generalising it off `Column`. |
| 6173 | let members = |
| 6174 | , |
| 6175 | , |
| 6176 | , |
| 6177 | ]; |
| 6178 | let kept: = members |
| 6179 | .iter |
| 6180 | .filter |
| 6181 | .map |
| 6182 | .collect; |
| 6183 | assert_eq!; |
| 6184 | |
| 6185 | |
| 6186 | |
| 6187 | |
| 6188 | // The row still identifies itself after everything droppable has gone, |
| 6189 | // which is the property the ladder exists for. |
| 6190 | assert_eq!; |
| 6191 | // A control is not a fact. Room comes out of what the row says, never |
| 6192 | // out of what it offers. |
| 6193 | assert_eq!; |
| 6194 | assert_eq!; |
| 6195 | assert_eq!; |
| 6196 | assert_eq!; |
| 6197 | // Tokens sit in the middle deliberately: a toned badge is often the |
| 6198 | // most scannable thing in a row, so it does not go first. |
| 6199 | assert_eq!; |
| 6200 | |
| 6201 | |
| 6202 | |
| 6203 | |
| 6204 | // The default is what every part did before flows existed, so a |
| 6205 | // description written against the old vocabulary keeps its rendering. |
| 6206 | assert_eq!; |
| 6207 | assert_eq!; |
| 6208 | assert_eq!; |
| 6209 | |
| 6210 | |
| 6211 | |
| 6212 | |
| 6213 | // `#[non_exhaustive]`'s cost, taken deliberately. A tier added upstream |
| 6214 | // reaches an old renderer as one line rather than as a build break, and |
| 6215 | // one line is the reading that cannot break a neighbour's layout. The |
| 6216 | // match in `lines` is what this holds; it fails if a new tier is given |
| 6217 | // an arm that returns something unbounded. |
| 6218 | for flow in |
| 6219 | assert!; |
| 6220 | |
| 6221 | |
| 6222 | |
| 6223 | |
| 6224 | |
| 6225 | // The default is the common case: a call waits, and nothing about it is |
| 6226 | // countable. A determinate bar is the exception and says so. |
| 6227 | assert_eq!; |
| 6228 | assert!; |
| 6229 | assert!; |
| 6230 | assert_eq!; |
| 6231 | |
| 6232 | |
| 6233 |