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 | //! # Reach, focus and the focus ring |
| 283 | //! |
| 284 | //! Three terms, and no others, for what 0.19.0 moved out of the description. |
| 285 | //! **Reach** is which things can take focus and in what order; a browser reads |
| 286 | //! it off the document, a TUI derives it from draw order, egui from its own id |
| 287 | //! stack. **Focus** is which reached thing has the keyboard right now: the |
| 288 | //! renderer's, live, never described and never round-tripped through a |
| 289 | //! description. The **focus ring** is the visible cue; the token (`focus-ring`, |
| 290 | //! derived by `makeover` from the action colour) is the one shared artifact and |
| 291 | //! the drawing is the renderer's. Retired as names for any of this: "focus |
| 292 | //! stroke", "focus cue", "wants focus". "Caret" is a different thing — the text |
| 293 | //! cursor inside a field — and keeps its name. |
| 294 | //! |
| 295 | //! # Where the description stops |
| 296 | //! |
| 297 | //! The rule is that a member is added when an app needs a fact the vocabulary |
| 298 | //! cannot state, and refused when what it wants is presentation it should be |
| 299 | //! asking a renderer for. That is the whole test. It is not a quota, and the |
| 300 | //! goal is every screen described. |
| 301 | //! |
| 302 | //! ## What the timeline refusal got wrong, 2026-08-15 |
| 303 | //! |
| 304 | //! This section used to read "a day-plan timeline, a kanban board and a |
| 305 | //! calendar are not describable here and will not become describable", and it |
| 306 | //! propagated: 12 files across three apps, three libraries and the design wiki |
| 307 | //! cited it, including audiofiles and the MNW server, neither of which has a |
| 308 | //! timeline. It is withdrawn, and [`Track`] is the member it was refusing. |
| 309 | //! |
| 310 | //! The error was pricing. The argument assumed a timeline needs a component |
| 311 | //! library's worth of vocabulary, and nobody measured it. Held against |
| 312 | //! goingson's `day-planning-render.js`, the members it actually needed and |
| 313 | //! could not get were two integers: where a thing starts, and how long it |
| 314 | //! lasts. Labels, gridlines, item bodies and tones were all furniture this |
| 315 | //! crate already named. A refusal that expensive should have carried a |
| 316 | //! measurement, and did not. |
| 317 | //! |
| 318 | //! The reasoning underneath it survives and is still the test: slot heights, |
| 319 | //! gridline colour, how overlapping things stack, which hour scrolls into view. |
| 320 | //! Those are presentation, they stay the renderer's, and [`Track`] carries none |
| 321 | //! of them. What changed is the conclusion, not the principle. |
| 322 | //! |
| 323 | //! A kanban board and a calendar have not been measured the same way. They are |
| 324 | //! open questions rather than settled refusals, and whoever needs one should |
| 325 | //! count the missing members first. |
| 326 | //! |
| 327 | //! [`Region::Bespoke`] remains for the genuinely app-owned, and its |
| 328 | //! justification does not depend on the withdrawn claim. The |
| 329 | //! description names the *place* and the app owns the contents, so a screen |
| 330 | //! containing a timeline is still a whole screen and still routable. Without |
| 331 | //! it, the four goingson screens that make the app worth using would need a |
| 332 | //! second, undescribed path beside the router, and two paths is how a |
| 333 | //! vocabulary starts drifting from its app again. |
| 334 | //! |
| 335 | //! [`Region::Widget`] sits between that limit and the primitives, and it does |
| 336 | //! not move the limit. A widget is an assembly of members this crate *already* |
| 337 | //! has, under a name a renderer may or may not recognise. Anything that needs a |
| 338 | //! member the vocabulary does not have is still a finding about the vocabulary |
| 339 | //! or still bespoke; naming an assembly buys no new expressive power, which is |
| 340 | //! exactly why it is safe to let the set grow outside this crate. |
| 341 | |
| 342 | |
| 343 | |
| 344 | /// A colour intent this crate refers to but never resolves. |
| 345 | /// |
| 346 | /// The string is the token name `makeover` publishes, so a renderer can look |
| 347 | /// it up without this crate knowing what colour came back. |
| 348 | |
| 349 | /// The `makeover` intent token this resolves against. |
| 350 | ; |
| 351 | |
| 352 | |
| 353 | /// Which way the light falls across a two-tone edge. |
| 354 | /// |
| 355 | /// The whole content of a bevel, once colour and thickness are deferred. The |
| 356 | /// light is always assumed to come from the top left: every consumer measured |
| 357 | /// agreed on that and none of them ever varied it, so it is an invariant here |
| 358 | /// rather than a parameter. |
| 359 | /// |
| 360 | /// # The two corners that belong to both edges |
| 361 | /// |
| 362 | /// Top-right and bottom-left are where the lit run meets the shaded one, and |
| 363 | /// the description's claim is that they belong to *both*. How a renderer says |
| 364 | /// that is its own business, because the answer is bounded by resolution and |
| 365 | /// not by taste: |
| 366 | /// |
| 367 | /// - A terminal cell is roughly 8x17 device pixels, so giving the whole corner |
| 368 | /// to one tone thickens that edge by a cell and reads as one run overrunning |
| 369 | /// the other. A half-cell glyph divides the cell already, so `makeover-tui` |
| 370 | /// splits it and recovers real information. Its box-drawing fallback cannot: |
| 371 | /// a single stroke has no half to give, so there both corners go to dark. |
| 372 | /// - A pixel bevel is a one-point stroke by default, which makes the corner a |
| 373 | /// one-point square. There is nothing to divide — a diagonal seam across one |
| 374 | /// point is sub-pixel, and antialiasing renders it as the blend a mitred join |
| 375 | /// already produces. So `makeover-immediate` mitres and is *not* diverging; |
| 376 | /// it is the same rule at a resolution where the split degenerates. |
| 377 | /// |
| 378 | /// Stated here so the difference reads as a decision rather than as drift. A |
| 379 | /// renderer with room to divide the corner should; one without should mitre or |
| 380 | /// pick the shaded tone, and neither is a bug. |
| 381 | |
| 382 | |
| 383 | /// Lit from the top left: light on top and left, dark on bottom and right. |
| 384 | Raised, |
| 385 | /// The same edge inverted, which is also the pressed state of anything |
| 386 | /// that draws itself [`Bevel::Raised`]. |
| 387 | Inset, |
| 388 | |
| 389 | |
| 390 | |
| 391 | /// The edge intents, as `(top_left, bottom_right)`. |
| 392 | /// |
| 393 | /// Split out from any painting because the inversion *is* the idea, and |
| 394 | /// it is the one part every renderer implements identically. |
| 395 | |
| 396 | pub const |
| 397 | match self |
| 398 | SelfRaised => , |
| 399 | SelfInset => , |
| 400 | |
| 401 | |
| 402 | |
| 403 | /// Pressing inverts. A raised control reads as inset while held. |
| 404 | /// |
| 405 | /// Stated here rather than left to each consumer because a cascade can |
| 406 | /// carry a pressed state and an immediate-mode renderer cannot: audiofiles |
| 407 | /// resolves this per call site, eighteen times. |
| 408 | |
| 409 | pub const |
| 410 | match self |
| 411 | SelfRaised => SelfInset, |
| 412 | SelfInset => SelfRaised, |
| 413 | |
| 414 | |
| 415 | |
| 416 | |
| 417 | /// One side of a bevel, named by the intent it takes. |
| 418 | |
| 419 | |
| 420 | /// The lit side. |
| 421 | Light, |
| 422 | /// The shadowed side. |
| 423 | Dark, |
| 424 | |
| 425 | |
| 426 | |
| 427 | |
| 428 | match self |
| 429 | SelfLight => "bevel-light", |
| 430 | SelfDark => "bevel-dark", |
| 431 | |
| 432 | |
| 433 | |
| 434 | |
| 435 | /// A surface intent a region is filled with. |
| 436 | /// |
| 437 | /// `#[non_exhaustive]`, so a renderer must carry a wildcard arm and a new |
| 438 | /// member is additive rather than breaking. Added 0.4.0, after [`Sunken`] |
| 439 | /// (an additive member, 0.3.0) hard-broke `makeover-tui` and |
| 440 | /// `makeover-immediate` at compile time and left neither able to move until |
| 441 | /// both published. The vocabulary exists to grow and the renderers exist to |
| 442 | /// disagree about how much of it they answer, so growth must not be a |
| 443 | /// lockstep event. The renderer's wildcard is not a hole: [`Fill`] is |
| 444 | /// resolved through a fallible lookup, and a missing intent is answered with |
| 445 | /// structure rather than with a substituted colour. |
| 446 | /// |
| 447 | /// [`Sunken`]: Fill::Sunken |
| 448 | |
| 449 | |
| 450 | |
| 451 | /// The page behind everything. |
| 452 | Page, |
| 453 | /// A surface lifted off the page: cards, controls, menus, toasts. |
| 454 | Raised, |
| 455 | /// A surface floating above the page rather than resting on it. |
| 456 | Overlay, |
| 457 | /// The inside of a well. |
| 458 | Well, |
| 459 | /// A surface set back from the one it sits on, by colour and nothing else. |
| 460 | /// |
| 461 | /// Not a well. A well is a hole with an edge, and the two are authored in |
| 462 | /// opposite directions: `makeover` derives `surface-well` by inverting |
| 463 | /// against the theme's own content colour, while `surface-sunken` is |
| 464 | /// authored and free to sit darker than raised (goingson's does). Naming |
| 465 | /// only the well left the recessed-with-no-edge surface unsayable, which is |
| 466 | /// what an unchosen tab is: it recedes so the chosen one can come forward, |
| 467 | /// and it carries no bevel of its own. |
| 468 | /// |
| 469 | /// Added 0.3.0, from goingson's tab strip, which hand-writes exactly this |
| 470 | /// and could not delete the line because no member described it. |
| 471 | Sunken, |
| 472 | |
| 473 | |
| 474 | // No `fallback` here, deliberately. An earlier cut had `Fill::Well` fall back |
| 475 | // to `Fill::Page` so a consumer on makeover 2.2.0, which has no `surface-well`, |
| 476 | // had something to paint. makeover-tui found that wrong within a day: page is |
| 477 | // the surface a well is usually cut into, so on a terminal that substitution |
| 478 | // produces exactly the invisibility it was meant to prevent, and the right |
| 479 | // answer there is a drawn edge rather than a different colour. |
| 480 | // |
| 481 | // Substituting one intent for another is renderer policy. The description says |
| 482 | // what the region is and stops. |
| 483 | |
| 484 | |
| 485 | |
| 486 | match self |
| 487 | SelfPage => "surface-page", |
| 488 | SelfRaised => "surface-raised", |
| 489 | SelfOverlay => "surface-overlay", |
| 490 | SelfWell => "surface-well", |
| 491 | SelfSunken => "surface-sunken", |
| 492 | |
| 493 | |
| 494 | |
| 495 | |
| 496 | /// How a region sits relative to the surface behind it. |
| 497 | /// |
| 498 | /// Fill and bevel are named together because naming them apart is what let |
| 499 | /// them disagree. Every consumer measured had at least one region carrying a |
| 500 | /// raised bevel over a recessed fill: audiofiles fixed it in `raised_frame` |
| 501 | /// and recorded the bug in its doc comment, and Balanced Breakfast still had |
| 502 | /// twelve of them a year later. A single name for the pair makes that |
| 503 | /// unrepresentable. |
| 504 | /// `#[non_exhaustive]` for the same reason as [`Fill`], and in the same |
| 505 | /// release: a depth this renderer has no drawing for should cost it a |
| 506 | /// wildcard arm, not a compile error and a wait on someone else's publish. |
| 507 | |
| 508 | |
| 509 | |
| 510 | /// Level with its surroundings. No edge. |
| 511 | Flat, |
| 512 | /// A card laid on the panel it sits in. |
| 513 | Raised, |
| 514 | /// A hole in the panel, with content down inside it. For anything the |
| 515 | /// user looks *into*: a table body, a tag tree, a text field. |
| 516 | Well, |
| 517 | /// Set back from what it sits on, by colour alone. No edge. |
| 518 | /// |
| 519 | /// The one member carrying a fill without a bevel, so a renderer cannot |
| 520 | /// assume the two arrive together. That is deliberate and it is still the |
| 521 | /// pairing rule: both halves come off the same `Depth`, so they cannot |
| 522 | /// disagree, and here one half is legitimately absent. |
| 523 | /// |
| 524 | /// Distinct from [`Depth::Flat`], which has no fill either and inherits. |
| 525 | /// Recessed and level-with are different claims, and only one of them |
| 526 | /// needs a colour. |
| 527 | Sunken, |
| 528 | /// A surface sitting *over* the page rather than in it. A modal, a popover, |
| 529 | /// a menu. |
| 530 | /// |
| 531 | /// Takes elevation and no bevel: a surface overlaying the page is lifted |
| 532 | /// off it, and a surface in the page is cut into it. That is the same |
| 533 | /// pairing rule the rest of the enum holds, applied to the one case where |
| 534 | /// the separation is not an edge at all — the lift and the scrim behind it |
| 535 | /// are already saying where the surface is. |
| 536 | /// |
| 537 | /// Every renderer had the surface before it had this variant. |
| 538 | /// `makeover-tui` carries `Palette::overlay`, `makeover-immediate` gained |
| 539 | /// `Palette::elevation` at 0.10.0, and `makeover-webview` emits |
| 540 | /// `--elevation-overlay`. What was missing was the route from a description |
| 541 | /// to any of them, which is why this is one variant rather than a feature. |
| 542 | Overlay, |
| 543 | |
| 544 | |
| 545 | |
| 546 | /// The edge this depth is drawn with, if it has one. |
| 547 | |
| 548 | pub const |
| 549 | match self |
| 550 | // Sunken joins Flat here, for the opposite reason: Flat has no edge |
| 551 | // because nothing separates it from its surroundings, and Sunken has |
| 552 | // none because its colour is already doing the separating. |
| 553 | SelfFlat | SelfSunken => None, |
| 554 | // A third reason to have no edge, which is why it gets its own arm |
| 555 | // rather than joining the two above: an overlay is separated by the |
| 556 | // lift and by the scrim behind it, so an edge would be a second |
| 557 | // answer to a question already answered. |
| 558 | SelfOverlay => None, |
| 559 | SelfRaised => Some, |
| 560 | SelfWell => Some, |
| 561 | |
| 562 | |
| 563 | |
| 564 | /// The surface this depth is filled with. |
| 565 | /// |
| 566 | /// [`Depth::Flat`] has no fill of its own: it inherits whatever it sits on, |
| 567 | /// which is the difference between level-with and painted-the-same-colour. |
| 568 | |
| 569 | pub const |
| 570 | match self |
| 571 | SelfFlat => None, |
| 572 | SelfRaised => Some, |
| 573 | SelfWell => Some, |
| 574 | SelfSunken => Some, |
| 575 | SelfOverlay => Some, |
| 576 | |
| 577 | |
| 578 | |
| 579 | /// Pressing a raised region reads as a well, and nothing else moves. |
| 580 | /// |
| 581 | /// [`Depth::Overlay`] is untouched along with the rest: an overlay is a |
| 582 | /// surface, not a control, so there is nothing there to press. |
| 583 | |
| 584 | pub const |
| 585 | match self |
| 586 | SelfRaised => SelfWell, |
| 587 | other => other, |
| 588 | |
| 589 | |
| 590 | |
| 591 | |
| 592 | /// An interaction state a region can be in, beside whatever [`Depth`] it is. |
| 593 | /// |
| 594 | /// Orthogonal to depth on purpose. A disabled button is still [`Depth::Raised`] |
| 595 | /// and a disabled field is still a [`Depth::Well`], so folding either member |
| 596 | /// into `Depth` would make [`Depth::bevel`] and [`Depth::fill`] answer for |
| 597 | /// something that is not a depth, and would leave disabled-button and |
| 598 | /// disabled-field sharing one variant that cannot tell them apart. |
| 599 | /// |
| 600 | /// # Why hover and pressed are not members |
| 601 | /// |
| 602 | /// The line is whether every renderer has the state to express, not whether CSS |
| 603 | /// does. Hover is renderer policy and `makeover-webview` says so in its own |
| 604 | /// header: a terminal and an immediate-mode painter have no pointer hovering |
| 605 | /// over anything, and pressed already arrives through [`Bevel::pressed`] and |
| 606 | /// [`Depth::pressed`], where it belongs, because pressing is a depth inversion |
| 607 | /// rather than a separate condition. |
| 608 | /// |
| 609 | /// Focus and disabled are different in kind. A TUI has a focused widget and a |
| 610 | /// greyed-out one; so does egui. Both were unsayable here, so all three webview |
| 611 | /// consumers supplied them from outside the primitive by out-specifying rules |
| 612 | /// they did not own: goingson alone carries 19 of them, and the MNW server |
| 613 | /// another 21. That is the divergence this crate exists to end, arriving one |
| 614 | /// layer down. |
| 615 | /// |
| 616 | /// # The principle this encodes |
| 617 | /// |
| 618 | /// A primitive owns every state it implies. A renderer that emits a hover rule |
| 619 | /// for a thing owes disabled and the capability answer for that same thing, |
| 620 | /// because anything less exports the completion work to N consumers who will |
| 621 | /// each do it differently. |
| 622 | /// |
| 623 | /// Focus is not on that list and was removed from this axis in 0.19.0. It is |
| 624 | /// the renderer's, decided after the description; see the crate header, "Reach, |
| 625 | /// focus and the focus ring", for the three terms and who owns each. |
| 626 | /// |
| 627 | /// `#[non_exhaustive]` for the reason [`Fill`] and [`Depth`] carry it: growth |
| 628 | /// must not be a lockstep event across the three renderers. |
| 629 | |
| 630 | |
| 631 | |
| 632 | /// Present, visible, and not answering. |
| 633 | /// |
| 634 | /// Not the same as absent, and deliberately not a [`Fill`]: a disabled |
| 635 | /// control keeps the surface it always had and stops responding, so what |
| 636 | /// changes is its content and its interactivity rather than what it is. |
| 637 | Disabled, |
| 638 | |
| 639 | |
| 640 | |
| 641 | /// Whether a region in this state stops answering the pointer. |
| 642 | /// |
| 643 | /// Stated in the description rather than left to each renderer, on the same |
| 644 | /// reasoning as [`Bevel::pressed`]: a cascade carries it for free and an |
| 645 | /// immediate-mode renderer resolves it per call site, so leaving it unsaid |
| 646 | /// means resolving it once per consumer and disagreeing. |
| 647 | |
| 648 | pub const |
| 649 | // A match rather than a bare `true`, so a member added to this |
| 650 | // `#[non_exhaustive]` axis has to answer the question rather than |
| 651 | // inheriting an answer. |
| 652 | match self |
| 653 | SelfDisabled => true, |
| 654 | |
| 655 | |
| 656 | |
| 657 | |
| 658 | |
| 659 | |
| 660 | match self |
| 661 | // Reusing the muted content intent rather than minting a |
| 662 | // `disabled` colour. Disabled is a reduction and not a status, and |
| 663 | // `makeover-webview`'s progress rules already record the reading |
| 664 | // that `content-muted` is what disabled looks like. |
| 665 | SelfDisabled => "content-muted", |
| 666 | |
| 667 | |
| 668 | |
| 669 | |
| 670 | /// What a region is saying, when it is saying something. |
| 671 | /// |
| 672 | /// The one intent family shared by badges, notices and nothing else. Kept |
| 673 | /// separate from [`Fill`] because a surface is where a thing sits and a tone is |
| 674 | /// what it means, and the three apps agree on the four statuses: |
| 675 | /// `info_banner` / `warning_banner` in audiofiles, `.toast-info` / |
| 676 | /// `.toast-success` / `.toast-error` in goingson, `.toast.success` / |
| 677 | /// `.toast.error` in Balanced Breakfast. |
| 678 | /// |
| 679 | /// The per-tag palette (`category-one` through `category-six`) is deliberately |
| 680 | /// not here. Which colour a *particular* tag takes is app domain, and both |
| 681 | /// webview apps already carry it as a `data-color` attribute. |
| 682 | |
| 683 | |
| 684 | /// No status. Reads as ordinary de-emphasised content. |
| 685 | Neutral, |
| 686 | /// Something worth knowing and nothing to do about it. |
| 687 | Info, |
| 688 | /// Something finished and it worked. |
| 689 | Success, |
| 690 | /// Something the user should look at before continuing. |
| 691 | Warning, |
| 692 | /// Something broken, or something about to be destroyed. |
| 693 | Danger, |
| 694 | |
| 695 | |
| 696 | |
| 697 | |
| 698 | match self |
| 699 | // Neutral has no status token of its own. It takes the muted |
| 700 | // content intent, which is what both webview apps already spell as |
| 701 | // `data-color="muted"`. |
| 702 | SelfNeutral => "content-muted", |
| 703 | SelfInfo => "info", |
| 704 | SelfSuccess => "success", |
| 705 | SelfWarning => "warning", |
| 706 | SelfDanger => "danger", |
| 707 | |
| 708 | |
| 709 | |
| 710 | |
| 711 | /// A small labelled thing that sits inside something else. |
| 712 | /// |
| 713 | /// Two members, because the three apps drew three taxonomies and only one line |
| 714 | /// runs through all of them: does it answer a click. audiofiles has |
| 715 | /// `classification_badge` (a label) against `tag_chip`, `tag_chip_removable` |
| 716 | /// and `selectable_tag` (all of which do). Balanced Breakfast has `.tag` and |
| 717 | /// `.badge` against `.tag-chip`. goingson is the one that has to move: its |
| 718 | /// `.tag` and `.badge` are a single CSS rule, so every call site has to be read |
| 719 | /// to decide which of the two it always was. |
| 720 | /// |
| 721 | /// The evidence that a chip is a real concept rather than a badge with a |
| 722 | /// cursor: audiofiles inverts its bevel on press and Balanced Breakfast latches |
| 723 | /// `.tag-chip.active` with the inset bevel. Two independent arrivals at "a chip |
| 724 | /// holds itself down", which is exactly what [`Depth::pressed`] already says. |
| 725 | |
| 726 | |
| 727 | /// Non-interactive status or count. Answers no click. |
| 728 | Badge, |
| 729 | /// An interactive or removable token. Answers a click, and latches if it |
| 730 | /// stands for a filter that is either on or off. |
| 731 | Chip |
| 732 | /// Whether it carries its own remove affordance. |
| 733 | removable: bool, |
| 734 | , |
| 735 | |
| 736 | |
| 737 | |
| 738 | /// Whether this answers a click. |
| 739 | /// |
| 740 | /// The whole difference between the two members, and the reason a renderer |
| 741 | /// with no hover (a touch surface, a terminal) can still tell them apart. |
| 742 | |
| 743 | pub const |
| 744 | matches! |
| 745 | |
| 746 | |
| 747 | /// How it sits, given whether it is currently latched down. |
| 748 | /// |
| 749 | /// A badge is flat: it is a label, and giving it an edge would say it can |
| 750 | /// be pressed. A chip is raised, and inset while latched. |
| 751 | |
| 752 | pub const |
| 753 | match self |
| 754 | SelfBadge => Flat, |
| 755 | SelfChip if latched => Well, |
| 756 | SelfChip => Raised, |
| 757 | |
| 758 | |
| 759 | |
| 760 | |
| 761 | /// Something the app is telling the user, unprompted. |
| 762 | /// |
| 763 | /// Two concepts, not one with a placement. They differ in more than where they |
| 764 | /// sit: a toast is transient, stacked and self-dismissing, and a banner is |
| 765 | /// persistent, in flow, one per region, and dismissed by fixing the condition |
| 766 | /// it reports. Folding them into one member with a placement parameter would |
| 767 | /// make lifetime, stacking and dismissal all placement-dependent, which is the |
| 768 | /// description leaking renderer policy. |
| 769 | /// |
| 770 | /// All three apps have banners: `info_banner` and `warning_banner` in |
| 771 | /// audiofiles, five of them in goingson (sync, sync-result, vacation-day, |
| 772 | /// timer-active, past-review), `.update-banner` in Balanced Breakfast. The two |
| 773 | /// webview apps also have toasts. So neither member is speculative, and no app |
| 774 | /// gains a concept it lacks except audiofiles, whose renderer may legitimately |
| 775 | /// decline to draw a toast at all. |
| 776 | |
| 777 | |
| 778 | /// Transient, stacked, dismisses itself. |
| 779 | Toast, |
| 780 | /// Persistent, in flow, one per region, dismissed by fixing the cause. |
| 781 | Banner, |
| 782 | |
| 783 | |
| 784 | |
| 785 | /// Whether it goes away on its own. |
| 786 | |
| 787 | pub const |
| 788 | matches! |
| 789 | |
| 790 | |
| 791 | /// How it sits. |
| 792 | /// |
| 793 | /// A toast floats above the page rather than resting on it, which is |
| 794 | /// [`Fill::Overlay`]'s whole reason to exist. A banner is a card in the |
| 795 | /// flow. Both are raised, and they are raised off different things. |
| 796 | |
| 797 | pub const |
| 798 | match self |
| 799 | SelfToast => Overlay, |
| 800 | SelfBanner => Raised, |
| 801 | |
| 802 | |
| 803 | |
| 804 | |
| 805 | /// The parts of a list row. |
| 806 | /// |
| 807 | /// Four to begin with, taken from Balanced Breakfast, which was the only |
| 808 | /// consumer that had all of them (`row-primary`, `row-secondary`, `row-meta`, |
| 809 | /// `row-actions`). audiofiles has two and no slot structure at all, so it gains |
| 810 | /// meta and actions as real work rather than a rename; goingson moves off |
| 811 | /// `task-row` / `task-cell`. |
| 812 | /// |
| 813 | /// [`Tokens`](Self::Tokens) joined at 0.9.0, and `#[non_exhaustive]` with it. |
| 814 | /// See the crate header for why the two arrived together. |
| 815 | /// |
| 816 | /// # Meta against Tokens |
| 817 | /// |
| 818 | /// The line is whether the thing has its own standing. `Meta` is one short |
| 819 | /// trailing fact about the row, written as text: a count, a size, a date. |
| 820 | /// `Tokens` is a set of small labelled things, each of which can be toned and |
| 821 | /// can answer a click. "3 files" is meta. A status badge that is amber, and a |
| 822 | /// tag you can click to filter by, are tokens. |
| 823 | /// |
| 824 | /// Keeping them apart is what a single widened slot would have foreclosed. A |
| 825 | /// renderer can right-align one string and cannot usefully do the same to a |
| 826 | /// strip of chips, and a fact that is not clickable should not be drawn as |
| 827 | /// though it were. |
| 828 | |
| 829 | |
| 830 | |
| 831 | /// The thing itself. What the row is called. |
| 832 | Primary, |
| 833 | /// Supporting text under the primary. |
| 834 | Secondary, |
| 835 | /// A short trailing fact: a count, a size, a date. |
| 836 | Meta, |
| 837 | /// Controls that act on this row. |
| 838 | Actions, |
| 839 | /// Small labelled things belonging to the row: badges, chips, tags. |
| 840 | /// |
| 841 | /// Each carries its own [`Token`] kind and [`Tone`], so a renderer with no |
| 842 | /// colour still has the kind to work with, and one with no chips still has |
| 843 | /// the label. That is the constrained-consumer test this vocabulary exists |
| 844 | /// to pass, and it is why the tone lives on the token rather than on the |
| 845 | /// part. |
| 846 | Tokens, |
| 847 | /// How much of a set the row's thing has done: a [`Meter`] in the row. |
| 848 | /// |
| 849 | /// Added 0.11.0, `da5666ae`, and it is [`Tokens`](Self::Tokens)'s problem |
| 850 | /// again with a different payload. [`Meter`] arrived at 0.10.0 and closed |
| 851 | /// two of the seven sites that asked for it; the other five sit in rows, and |
| 852 | /// a row holds no nodes by the ruling that a row part may not carry an |
| 853 | /// arbitrary node — the door through which a description becomes a |
| 854 | /// templating language. So the part carries the *description of a bar* |
| 855 | /// rather than a node, exactly as `Tokens` carries tags rather than nodes. |
| 856 | /// |
| 857 | /// Without it a row flattens the proportion into [`Meta`](Self::Meta) as |
| 858 | /// "3/7 subtasks", which keeps both numbers and loses the reading, the same |
| 859 | /// way a toned status badge read as prose before `Tokens`. |
| 860 | Proportion, |
| 861 | |
| 862 | |
| 863 | |
| 864 | /// The content intent the part takes. |
| 865 | |
| 866 | pub const |
| 867 | match self |
| 868 | SelfPrimary => "content", |
| 869 | SelfSecondary => "content-secondary", |
| 870 | SelfMeta => "content-muted", |
| 871 | // Actions carry controls rather than text, so they inherit. |
| 872 | SelfActions => "content", |
| 873 | // So do tokens: each one carries its own tone, and a part-level |
| 874 | // intent underneath it would fight the token that sits on it. |
| 875 | SelfTokens => "content", |
| 876 | // And so does a proportion, for the same reason: the meter carries |
| 877 | // the tone, and it is about the ratio rather than about the row. |
| 878 | SelfProportion => "content", |
| 879 | |
| 880 | |
| 881 | |
| 882 | |
| 883 | /// How far down the heading tree a title sits. |
| 884 | /// |
| 885 | /// Three, and only the three that are actually headings. The bands those used |
| 886 | /// to be filed with (goingson's `.page-header`, Balanced Breakfast's `.header` |
| 887 | /// and `.detail-header`) are arrangement, not type, and live at |
| 888 | /// [`Region::Band`]. One of them contains no text at all. |
| 889 | |
| 890 | |
| 891 | /// Names the whole screen. One per screen. |
| 892 | Page, |
| 893 | /// Names a block within the screen. |
| 894 | Section, |
| 895 | /// Names a sub-block inside an already-named section. |
| 896 | Subsection, |
| 897 | |
| 898 | |
| 899 | |
| 900 | /// Whether a rule follows the heading. |
| 901 | /// |
| 902 | /// audiofiles' `section_header` draws a separator and its |
| 903 | /// `subsection_label` deliberately does not, which is the only thing |
| 904 | /// distinguishing the two once weight and colour are deferred. |
| 905 | |
| 906 | pub const |
| 907 | matches! |
| 908 | |
| 909 | |
| 910 | |
| 911 | /// A control that picks between things. |
| 912 | /// |
| 913 | /// Three, because three distinct behaviours are in play and collapsing any two |
| 914 | /// loses something. A segmented control picks a value; a tab picks a pane; a |
| 915 | /// toggle picks nothing and simply holds itself on or off. |
| 916 | |
| 917 | |
| 918 | /// Exactly one of N, and the options abut. |
| 919 | Segmented, |
| 920 | /// Independent on or off, on its own. |
| 921 | Toggle, |
| 922 | /// Navigation between panes. The folder semantic. |
| 923 | Tabs, |
| 924 | |
| 925 | |
| 926 | |
| 927 | /// How the chosen option sits. |
| 928 | /// |
| 929 | /// Held in for a segmented control and a toggle, which is the same shape |
| 930 | /// pressing produces and the whole economy of the idiom: one appearance, |
| 931 | /// two reasons to wear it. A tab is the exception, because the selected |
| 932 | /// folder tab comes *forward* to join the pane it opens. |
| 933 | |
| 934 | pub const |
| 935 | match self |
| 936 | SelfSegmented | SelfToggle => Well, |
| 937 | SelfTabs => Raised, |
| 938 | |
| 939 | |
| 940 | |
| 941 | /// How the options that were *not* picked sit. |
| 942 | /// |
| 943 | /// Added 0.3.0. Describing only [`Selector::chosen`] left the unchosen |
| 944 | /// option falling through to [`Depth::Flat`], which says it is level with |
| 945 | /// the strip it sits in, and no renderer emitted anything for it. That is |
| 946 | /// wrong in both directions and goingson proved it: its unchosen tabs are |
| 947 | /// recessed by hand, and being recessed is *why* the chosen one reads as |
| 948 | /// coming forward. Against a flat strip, a raised chosen tab is a bevel |
| 949 | /// drawn on the strip's own colour, which is a much weaker folder effect |
| 950 | /// than the contrast the idiom is named after. |
| 951 | /// |
| 952 | /// Each member is the inverse of its chosen state, which is the whole |
| 953 | /// content of "picked" once colour is deferred: |
| 954 | /// |
| 955 | /// - Tabs recede, so the chosen one comes forward. |
| 956 | /// - A segment and a toggle stand up, so the chosen one is held in. |
| 957 | |
| 958 | pub const |
| 959 | match self |
| 960 | SelfTabs => Sunken, |
| 961 | SelfSegmented | SelfToggle => Raised, |
| 962 | |
| 963 | |
| 964 | |
| 965 | /// Whether the options touch. |
| 966 | /// |
| 967 | /// The gap is the entire difference between a segmented control and a row |
| 968 | /// of buttons that happen to sit near each other, which is what audiofiles' |
| 969 | /// `segmented_control` says in its own comment and why it zeroes the |
| 970 | /// spacing by hand. |
| 971 | |
| 972 | pub const |
| 973 | matches! |
| 974 | |
| 975 | |
| 976 | |
| 977 | /// What is in a region right now. |
| 978 | /// |
| 979 | /// The state, not the shimmer. Whether pending paints a skeleton, a spinner or |
| 980 | /// nothing at all is renderer policy, the same class of decision that got |
| 981 | /// `Fill::fallback` deleted from this crate. goingson and Balanced Breakfast |
| 982 | /// each grew a skeleton with differently-named parts; both keep them, as the |
| 983 | /// webview renderer's expression of [`Readiness::Pending`]. audiofiles has none |
| 984 | /// and needs none, because an immediate-mode renderer simply repaints. |
| 985 | /// |
| 986 | /// # Four states and not two, as of 0.12.0 |
| 987 | /// |
| 988 | /// `703f4cd2`. It named `Ready` and `Pending` and stopped, so a described screen |
| 989 | /// whose list came back empty had to render an empty region or invent its own |
| 990 | /// placeholder text, and neither says what it is. goingson draws one at 27 sites |
| 991 | /// across 12 files and Balanced Breakfast at 9, with a class family that had |
| 992 | /// already drifted into `empty-state`, `empty-state--error`, `error-state` and |
| 993 | /// six more. |
| 994 | /// |
| 995 | /// The four are one axis because they are mutually exclusive: a region shows its |
| 996 | /// content, or a sign that it is coming, or a sign that there is none, or a sign |
| 997 | /// that it broke. Never two. That is the test for one enum against several |
| 998 | /// fields, and it is why this grew rather than a new member arriving beside it. |
| 999 | /// |
| 1000 | /// # What is not here |
| 1001 | /// |
| 1002 | /// **The message.** "No projects yet" is content, and this names a state. It |
| 1003 | /// lives with whatever holds the region — in quasi's case a `Slot` — alongside |
| 1004 | /// the action that leads out of the emptiness, since an address is the one thing |
| 1005 | /// this crate never names. |
| 1006 | /// |
| 1007 | /// **How much room it gets.** goingson's `--compact`, `--dashboard` and |
| 1008 | /// `--padded` are the same state at three sizes, and a size is |
| 1009 | /// `makeover-geometry`'s question. Naming them here would be this crate stating |
| 1010 | /// values again. |
| 1011 | /// |
| 1012 | /// **The icon.** Presentation, and each host has its own answer or none. |
| 1013 | |
| 1014 | |
| 1015 | |
| 1016 | /// The content is here. |
| 1017 | Ready, |
| 1018 | /// The content is on its way. |
| 1019 | Pending, |
| 1020 | /// The content arrived and there is none of it. |
| 1021 | /// |
| 1022 | /// Not a failure. An empty list is the normal state of a new install, and a |
| 1023 | /// renderer that drew it in a danger tone would be reporting a fault where |
| 1024 | /// there is none. |
| 1025 | Empty, |
| 1026 | /// The content did not arrive. |
| 1027 | Failed, |
| 1028 | |
| 1029 | |
| 1030 | |
| 1031 | /// Whether the region draws its own content, or something standing in for |
| 1032 | /// it. |
| 1033 | /// |
| 1034 | /// The question every renderer asks first, so it is answered once here |
| 1035 | /// rather than by a `matches!` in each. A state added later is a stand-in |
| 1036 | /// until proven otherwise: falling back to drawing content that may not be |
| 1037 | /// there is the worse of the two mistakes. |
| 1038 | |
| 1039 | pub const |
| 1040 | matches! |
| 1041 | |
| 1042 | |
| 1043 | /// What the state means, for a renderer choosing a colour. |
| 1044 | /// |
| 1045 | /// Derived rather than carried, which is the opposite of [`Meter`] and |
| 1046 | /// [`Figure`], and the difference is worth stating: a proportion's meaning |
| 1047 | /// depends on what is being counted and only the app knows it, while |
| 1048 | /// "nothing here yet" and "this broke" mean the same thing in every app that |
| 1049 | /// will ever have them. |
| 1050 | |
| 1051 | pub const |
| 1052 | match self |
| 1053 | SelfFailed => Danger, |
| 1054 | _ => Neutral, |
| 1055 | |
| 1056 | |
| 1057 | |
| 1058 | |
| 1059 | /// How much of a set is done. |
| 1060 | /// |
| 1061 | /// Added 0.10.0. Nine sites across the two webview apps drew a bar and nothing |
| 1062 | /// here named one, so every described screen concatenated the two numbers into |
| 1063 | /// its heading text instead: "Subtasks 3/7", "Time Tracking 45m tracked / 30m |
| 1064 | /// est, over". Every fact survives that and the reading does not, which is the |
| 1065 | /// same loss `RowPart::Tokens` closed when a toned status badge became prose. |
| 1066 | /// |
| 1067 | /// # Why a pair and not a percentage |
| 1068 | /// |
| 1069 | /// Both numbers, not the percentage the apps compute from them. The percentage |
| 1070 | /// was the obvious shape and it had already been tried: goingson's |
| 1071 | /// `Task::time_progress` divides, rounds, and then clamps to 100, which throws |
| 1072 | /// away the one case the bar exists to show — 45 minutes tracked against a |
| 1073 | /// 30-minute estimate. It carries a separate `is_over_estimate` boolean beside |
| 1074 | /// it to recover the fact the clamp dropped. A pair keeps the over-run without a |
| 1075 | /// companion flag, and [`percent`](Meter::percent) is still one call away for a |
| 1076 | /// renderer that wants it. |
| 1077 | /// |
| 1078 | /// The pair is also what the apps already have at every site. All seven |
| 1079 | /// determinate bars write the ratio into the accessible layer and never the |
| 1080 | /// percentage: `title="3/7 subtasks"`, `aria-label="3 of 7 subtasks completed"`, |
| 1081 | /// a milestone's own `3/7` span. Given 43 nothing can recover "3 of 7", so a |
| 1082 | /// percentage member would have made [`label`](Meter::label) mandatory at every |
| 1083 | /// call site, which is the concatenated text this member removes, moved one |
| 1084 | /// layer down. |
| 1085 | /// |
| 1086 | /// # What this is not |
| 1087 | /// |
| 1088 | /// The progress of an *operation*. Two of the nine sites are that — goingson's |
| 1089 | /// focus timer, Balanced Breakfast's feed fetch — and they get nothing here, on |
| 1090 | /// purpose. Both are imperative controllers over a live handle, driven by a tick |
| 1091 | /// or an event stream, and a description is built once and dropped. Holding one |
| 1092 | /// would mean growing a way to update a description between renders, which is a |
| 1093 | /// different feature. [`Readiness::Pending`] and a [`Notice::Toast`] carry the |
| 1094 | /// honest part. |
| 1095 | /// |
| 1096 | /// The two cases are distinguishable in the markup rather than by taste: every |
| 1097 | /// determinate bar in both apps carries a tone, and neither operation bar |
| 1098 | /// carries one. Two codebases drew that line the same way without coordinating. |
| 1099 | |
| 1100 | |
| 1101 | /// How much is done. May exceed [`total`](Self::total), and that is the |
| 1102 | /// case worth drawing. |
| 1103 | pub done: u32, |
| 1104 | /// How much there is to do. Zero means there is no set, not that the set is |
| 1105 | /// complete. |
| 1106 | pub total: u32, |
| 1107 | /// What the proportion means right now. |
| 1108 | /// |
| 1109 | /// Carried rather than derived, because no renderer can work it out. The |
| 1110 | /// same 90% is [`Tone::Success`] on a subtask rollup and [`Tone::Danger`] on |
| 1111 | /// a time estimate, and goingson picks between them from `is_over_estimate`, |
| 1112 | /// a fact about the data and not about the number. |
| 1113 | pub tone: Tone, |
| 1114 | /// What is being counted, if the bar says so: "subtasks", "tasks". |
| 1115 | /// |
| 1116 | /// The noun, not the ratio. A renderer builds "3 of 7 subtasks" from this |
| 1117 | /// and the two numbers; handing it the assembled string would put the |
| 1118 | /// sentence order in the description, where a terminal at one line and a |
| 1119 | /// tooltip want different ones. |
| 1120 | pub label: , |
| 1121 | |
| 1122 | |
| 1123 | |
| 1124 | /// A proportion with no tone and no label. |
| 1125 | |
| 1126 | pub const |
| 1127 | Self |
| 1128 | done, |
| 1129 | total, |
| 1130 | tone: Neutral, |
| 1131 | label: None, |
| 1132 | |
| 1133 | |
| 1134 | |
| 1135 | /// What the proportion means. |
| 1136 | |
| 1137 | pub const |
| 1138 | self.tone = tone; |
| 1139 | self |
| 1140 | |
| 1141 | |
| 1142 | /// What is being counted. |
| 1143 | |
| 1144 | pub const |
| 1145 | self.label = Some; |
| 1146 | self |
| 1147 | |
| 1148 | |
| 1149 | /// How full the bar is, 0 to 100, clamped. |
| 1150 | /// |
| 1151 | /// For drawing, which is the only thing a clamped number is good for. Ask |
| 1152 | /// [`overflowing`](Self::overflowing) before reporting it as a fact, or this |
| 1153 | /// is `time_progress`'s bug again with the clamp moved. |
| 1154 | /// |
| 1155 | /// An empty set reads as 0. Nothing is done, because there is nothing to do |
| 1156 | /// and no bar to fill; the apps guard on the count before drawing at all. |
| 1157 | |
| 1158 | pub const |
| 1159 | if self.total == 0 |
| 1160 | return 0; |
| 1161 | |
| 1162 | let scaled = / self.total as u64; |
| 1163 | if scaled > 100 else |
| 1164 | |
| 1165 | |
| 1166 | /// Whether more is done than there was to do. |
| 1167 | /// |
| 1168 | /// The fact [`percent`](Self::percent) destroys, kept reachable so a |
| 1169 | /// renderer can mark the over-run rather than drawing a full bar and |
| 1170 | /// implying it landed exactly. |
| 1171 | |
| 1172 | pub const |
| 1173 | self.done > self.total |
| 1174 | |
| 1175 | |
| 1176 | /// Whether there is a set at all. |
| 1177 | /// |
| 1178 | /// A meter over nothing is sayable on purpose, for the same reason a field |
| 1179 | /// with no options is: it is what an app with an unloaded count actually |
| 1180 | /// has, and a renderer that shows an empty bar says so on screen rather than |
| 1181 | /// dividing by zero. |
| 1182 | |
| 1183 | pub const |
| 1184 | self.total == 0 |
| 1185 | |
| 1186 | |
| 1187 | |
| 1188 | /// One figure with a caption: a number and what it counts. |
| 1189 | /// |
| 1190 | /// The dashboard shape. A large value over a small caption, several of them in a |
| 1191 | /// strip: a current streak, a completion rate, a total. Added 0.11.0, |
| 1192 | /// `93c6a174`, after goingson turned out to have five of them across five |
| 1193 | /// screens with five class vocabularies for the one shape — `task-overview-stat`, |
| 1194 | /// `stat-box`, `month-stat-item`, `contact-summary-stat`, `sync-stat`. Four put |
| 1195 | /// the value above the caption and one inverts it, which is drift inside the |
| 1196 | /// shape rather than a second shape. |
| 1197 | /// |
| 1198 | /// # Why the value is text |
| 1199 | /// |
| 1200 | /// "17", "84%", "12/30", "3d". A figure is whatever the app computed, already |
| 1201 | /// formatted, and the formatting is the app's because only it knows whether the |
| 1202 | /// number is a percentage, a duration or a ratio. This carries none of the |
| 1203 | /// arithmetic [`Meter`] carries, and that is the difference between them: a |
| 1204 | /// meter is a proportion a renderer draws, and a figure is a fact a renderer |
| 1205 | /// sets in type. |
| 1206 | /// |
| 1207 | /// # Tone is carried, for [`Meter`]'s reason |
| 1208 | /// |
| 1209 | /// Three of the five sites tone the figure by their own means — `red`/`blue` on |
| 1210 | /// the weekly review, a `${type}` class on the monthly one, `sync-stat-warn` on |
| 1211 | /// sync. So tone is carried at every site that needs it and derived at none, and |
| 1212 | /// no renderer can work out that a streak of zero is worth colouring. |
| 1213 | /// |
| 1214 | /// # What is not here |
| 1215 | /// |
| 1216 | /// Whether the figure answers a click. One of the five is a control — sync's |
| 1217 | /// "Not Applied: 3" opens the list — and an action is not something this crate |
| 1218 | /// can name: nothing here knows what a route is. That belongs beside the figure |
| 1219 | /// in whatever layer holds the actions, the same way a row's activation sits |
| 1220 | /// beside its parts rather than inside them. |
| 1221 | /// |
| 1222 | /// The arrangement is not here either. Several figures in a strip is a set, and |
| 1223 | /// a renderer given them one at a time cannot tell it is looking at one; the |
| 1224 | /// layer that holds the tree is where the set gets said. |
| 1225 | |
| 1226 | |
| 1227 | /// The number, formatted the way the app means it to read. |
| 1228 | pub value: &'a str, |
| 1229 | /// What it counts. The caption under the value. |
| 1230 | pub caption: &'a str, |
| 1231 | /// How the value has moved, if the app is tracking that. |
| 1232 | /// |
| 1233 | /// Added 0.13.0. Text, for [`value`](Self::value)'s reason: only the app |
| 1234 | /// knows whether a move reads as `+12.5%`, `+3` or `2x`, and a renderer |
| 1235 | /// handed a number would have to guess. |
| 1236 | /// |
| 1237 | /// This is what [`tone`](Self::tone) was for and had no consumer of. The MNW |
| 1238 | /// server has four screens whose stat card is a label, a value and a delta, |
| 1239 | /// and the delta is the toned part: the figure itself is an ordinary fact |
| 1240 | /// and it is the movement that reads as good or bad. Without this the delta |
| 1241 | /// has to be folded into the caption, which loses the tone and reads as a |
| 1242 | /// longer caption rather than as a second, smaller line. |
| 1243 | pub change: , |
| 1244 | /// What the figure means right now. [`Tone::Neutral`] is an ordinary fact. |
| 1245 | /// |
| 1246 | /// Applies to [`change`](Self::change) where there is one, since that is the |
| 1247 | /// part that carries the judgement, and to the value where there is not. |
| 1248 | pub tone: Tone, |
| 1249 | |
| 1250 | |
| 1251 | |
| 1252 | /// A figure that is an ordinary fact. |
| 1253 | |
| 1254 | pub const |
| 1255 | Self |
| 1256 | value, |
| 1257 | caption, |
| 1258 | change: None, |
| 1259 | tone: Neutral, |
| 1260 | |
| 1261 | |
| 1262 | |
| 1263 | /// How the value has moved. |
| 1264 | |
| 1265 | pub const |
| 1266 | self.change = Some; |
| 1267 | self |
| 1268 | |
| 1269 | |
| 1270 | /// What the figure means. |
| 1271 | |
| 1272 | pub const |
| 1273 | self.tone = tone; |
| 1274 | self |
| 1275 | |
| 1276 | |
| 1277 | |
| 1278 | /// Something the user can do, and what it costs to say so. |
| 1279 | /// |
| 1280 | /// Added 0.17.0, out of `quasi-tui`: the terminal renderer had drawn one of |
| 1281 | /// these for months and every other consumer that wanted a button had written |
| 1282 | /// its own, because this layer named [`RowPart::Actions`] as a *slot* and never |
| 1283 | /// named the thing that goes in it. Beside [`Meter`] and [`Figure`] for the |
| 1284 | /// reason those are here: a renderer that is handed the parts has to decide how |
| 1285 | /// to say them, and a renderer that is handed a finished string has already had |
| 1286 | /// the decision made for it. |
| 1287 | /// |
| 1288 | /// No address. Where a control goes is the app's business and every host |
| 1289 | /// follows it differently — an `hx-get`, a protocol URL, a function call — so |
| 1290 | /// the description says what the control *is* and the caller keeps what it |
| 1291 | /// does. That is the same split [`Choice`] makes. |
| 1292 | /// |
| 1293 | /// No confirmation flag either, and that one is a finding rather than an |
| 1294 | /// omission: a question asked *after* a control is pressed belongs to whatever |
| 1295 | /// is holding the interaction, and a renderer that drew it would be asking |
| 1296 | /// before there was anything to answer. |
| 1297 | /// How a picture sits in the box it is given. |
| 1298 | /// |
| 1299 | /// An intent rather than a value, so a renderer picks the expression it has: |
| 1300 | /// `object-fit` in a webview, a texture's UV rect in egui, and in a terminal a |
| 1301 | /// choice about how many cells the blit gets. Named because MNW already makes |
| 1302 | /// the distinction deliberately at 17 sites and makes it three different ways, |
| 1303 | /// which is a policy the app decided rather than one a shared crate would be |
| 1304 | /// picking by accident. |
| 1305 | |
| 1306 | |
| 1307 | |
| 1308 | /// The picture's own proportions, and the box takes the height they imply. |
| 1309 | /// |
| 1310 | /// The default because it is the only one that shows the whole picture at |
| 1311 | /// its own shape, so a renderer that ignores this enum entirely is still |
| 1312 | /// right about the common case. A screenshot wants this; the shipped MNW |
| 1313 | /// carousel sets no `object-fit` at all, which is this. |
| 1314 | |
| 1315 | Natural, |
| 1316 | /// Fill the box and crop whatever does not fit. |
| 1317 | /// |
| 1318 | /// For a picture in a slot whose shape the layout fixed: a thumbnail, an |
| 1319 | /// avatar, cover art. 15 of MNW's 17 sites. |
| 1320 | Cover, |
| 1321 | /// Fit inside the box whole, leaving space on two sides. |
| 1322 | /// |
| 1323 | /// The letterbox. For when the whole picture matters more than filling the |
| 1324 | /// space, and the space is not the picture's shape. |
| 1325 | Contain, |
| 1326 | |
| 1327 | |
| 1328 | /// A picture, and what it says to someone who is not looking at it. |
| 1329 | /// |
| 1330 | /// # No source |
| 1331 | /// |
| 1332 | /// [`Act`]'s split, for [`Act`]'s reason. A source is an address, and this |
| 1333 | /// crate has no notion of an address: it says what a thing *is* and the caller |
| 1334 | /// keeps what it points at. The three findings dropped from 0.11.0 were all |
| 1335 | /// this same shape. |
| 1336 | /// |
| 1337 | /// It matters more here than it does for a control, because a picture is the |
| 1338 | /// one member where the address is most of what a webview needs and *none* of |
| 1339 | /// what the description knows. `quasi_router::Node::Image` carries the URL, the |
| 1340 | /// way it carries an `Action` for a control. |
| 1341 | /// |
| 1342 | /// # Why [`alt`](Self::alt) is not optional |
| 1343 | /// |
| 1344 | /// Every other host has to draw something, and for two of the three the alt |
| 1345 | /// text is not a fallback but the whole rendering: a terminal without a |
| 1346 | /// graphics protocol has the words and nothing else. Making it optional would |
| 1347 | /// make "this picture is invisible on a terminal" the default, and the |
| 1348 | /// description would be carrying a webview assumption in its shape. |
| 1349 | /// |
| 1350 | /// An image that genuinely says nothing — a rule, a spacer, a decoration |
| 1351 | /// repeating what the text beside it already said — is an empty `alt`, which is |
| 1352 | /// the same thing HTML means by it and is a claim rather than an oversight. |
| 1353 | |
| 1354 | |
| 1355 | /// What the picture says, for anything not showing it. |
| 1356 | /// |
| 1357 | /// Empty means the picture is decorative and adds nothing to the text |
| 1358 | /// around it. See the type's own docs on why this is not an `Option`. |
| 1359 | pub alt: &'a str, |
| 1360 | /// A visible line under the picture, where the app wants one. |
| 1361 | /// |
| 1362 | /// Distinct from [`alt`](Self::alt) and the difference is who it is for: a |
| 1363 | /// caption is content everybody reads, alt text is what stands in for the |
| 1364 | /// picture. A screenshot captioned "The library view" still needs alt text |
| 1365 | /// describing what is in the shot. |
| 1366 | pub caption: , |
| 1367 | /// How it sits in the box it is given. |
| 1368 | pub fit: Fit, |
| 1369 | /// The picture's own dimensions, where the app knows them. |
| 1370 | /// |
| 1371 | /// **Not a display size**, and that distinction is what makes this belong |
| 1372 | /// here rather than fall foul of the deferral rule. Saying a picture should |
| 1373 | /// be 320 points wide is a layout value and is not the description's to |
| 1374 | /// give. Saying the file is 5120x3412 is a fact *about the picture*, the |
| 1375 | /// same kind of fact [`alt`](Self::alt) is, and no renderer can find it out |
| 1376 | /// without fetching the bytes. |
| 1377 | /// |
| 1378 | /// # What it is for, and it is not decoration |
| 1379 | /// |
| 1380 | /// Without it a renderer cannot reserve room, so the picture occupies |
| 1381 | /// nothing until it arrives and then takes its full height at once, |
| 1382 | /// shoving everything below it down the screen. Measured on MNW's landing |
| 1383 | /// page 2026-08-14: a 478px jump per frame, and a cumulative layout shift |
| 1384 | /// of 0.087 for the page, which is most of the way to the 0.1 that counts |
| 1385 | /// as bad. |
| 1386 | /// |
| 1387 | /// Every host wants it and none can derive it. A webview writes `width` and |
| 1388 | /// `height` so the browser holds the space; egui sizes a texture; a |
| 1389 | /// terminal with a graphics protocol scales a blit into cells. This was |
| 1390 | /// missing from 0.21.0, which is the release that added [`Image`], and its |
| 1391 | /// absence is the defect rather than an omission. |
| 1392 | /// |
| 1393 | /// `None` is honest and common: a creator-uploaded image whose dimensions |
| 1394 | /// the app never recorded genuinely does not know. It means the renderer |
| 1395 | /// cannot reserve, not that the picture has no size. |
| 1396 | pub intrinsic: , |
| 1397 | /// Whether the picture is needed with the screen, or can arrive later. |
| 1398 | pub loading: Loading, |
| 1399 | |
| 1400 | |
| 1401 | /// A picture's own pixel dimensions. |
| 1402 | /// |
| 1403 | /// Deliberately not [`makeover_geometry`]'s business. Geometry answers *how |
| 1404 | /// much space a thing should get*, which is a scale question with the same |
| 1405 | /// answer on every screen. This is the intrinsic size of one asset, which is a |
| 1406 | /// fact about that asset and varies per picture. |
| 1407 | /// |
| 1408 | /// [`makeover_geometry`]: https://docs.rs/makeover-geometry |
| 1409 | |
| 1410 | |
| 1411 | /// Width in the picture's own pixels. |
| 1412 | pub width: u32, |
| 1413 | /// Height in the picture's own pixels. |
| 1414 | pub height: u32, |
| 1415 | |
| 1416 | |
| 1417 | |
| 1418 | /// A picture's dimensions. |
| 1419 | |
| 1420 | pub const |
| 1421 | Self |
| 1422 | |
| 1423 | |
| 1424 | /// Width over height, or `None` if either side is zero. |
| 1425 | /// |
| 1426 | /// The form a renderer actually reserves space with: a box that knows its |
| 1427 | /// proportion holds the right height at any width, which is what a |
| 1428 | /// responsive picture needs and what a fixed pixel height cannot give. |
| 1429 | |
| 1430 | |
| 1431 | .then |
| 1432 | |
| 1433 | |
| 1434 | |
| 1435 | /// When a picture is needed. |
| 1436 | /// |
| 1437 | /// A claim about *importance and position* rather than a fetch mechanism, which |
| 1438 | /// is why it is the description's to make: only the app knows whether a picture |
| 1439 | /// is the first thing on the screen or the fortieth thing down a list. |
| 1440 | /// |
| 1441 | /// # Eager is the default, and that is a correctness choice |
| 1442 | /// |
| 1443 | /// 0.21.0 emitted the webview's `loading="lazy"` for every picture, on the |
| 1444 | /// evidence that the one consumer measured wrote it. That was reading a habit |
| 1445 | /// as a rule. Deferring a picture that is on screen at first paint does not |
| 1446 | /// save anything -- it is needed immediately either way -- and it delays the |
| 1447 | /// arrival, so the space it eventually takes is claimed later and the shift is |
| 1448 | /// more visible, not less. |
| 1449 | /// |
| 1450 | /// So the safe answer is the default and the optimisation is opted into. A |
| 1451 | /// carousel is the case that proves the two cannot be one setting for the |
| 1452 | /// renderer to choose: its first frame is on screen and its other frames are |
| 1453 | /// not, in the same widget, at the same moment. |
| 1454 | |
| 1455 | |
| 1456 | |
| 1457 | /// Needed with the screen. Fetch it now. |
| 1458 | |
| 1459 | Eager, |
| 1460 | /// Not on screen yet. It can wait until it is near. |
| 1461 | Lazy, |
| 1462 | |
| 1463 | |
| 1464 | |
| 1465 | /// A picture that carries its own proportions. |
| 1466 | |
| 1467 | pub const |
| 1468 | Self |
| 1469 | alt, |
| 1470 | caption: None, |
| 1471 | fit: Natural, |
| 1472 | intrinsic: None, |
| 1473 | loading: Eager, |
| 1474 | |
| 1475 | |
| 1476 | |
| 1477 | /// The picture's own dimensions, so a renderer can hold its place. |
| 1478 | |
| 1479 | pub const |
| 1480 | self.intrinsic = Some; |
| 1481 | self |
| 1482 | |
| 1483 | |
| 1484 | /// This picture is not on screen yet; it can arrive when it is near. |
| 1485 | |
| 1486 | pub const |
| 1487 | self.loading = Lazy; |
| 1488 | self |
| 1489 | |
| 1490 | |
| 1491 | /// A visible line under it. |
| 1492 | |
| 1493 | pub const |
| 1494 | self.caption = Some; |
| 1495 | self |
| 1496 | |
| 1497 | |
| 1498 | /// How it sits in its box. |
| 1499 | |
| 1500 | pub const |
| 1501 | self.fit = fit; |
| 1502 | self |
| 1503 | |
| 1504 | |
| 1505 | /// Whether the picture adds anything for someone not looking at it. |
| 1506 | /// |
| 1507 | /// A renderer with no way to show a picture uses this to decide between |
| 1508 | /// drawing the alt text and drawing nothing at all. Both are correct and |
| 1509 | /// the difference is this flag: standing in for a decorative rule with the |
| 1510 | /// word "decoration" is worse than leaving the space empty. |
| 1511 | |
| 1512 | pub const |
| 1513 | !self.alt.is_empty |
| 1514 | |
| 1515 | |
| 1516 | |
| 1517 | /// A window of time, in minutes from the start of a day. |
| 1518 | /// |
| 1519 | /// The axis a [`Track`] draws. Minutes rather than instants, and offsets rather |
| 1520 | /// than wall-clock, because a description that carried a `DateTime` would carry |
| 1521 | /// a timezone with it and the vocabulary has no business holding one. The app |
| 1522 | /// knows which day this is; the description says how far along it a thing sits. |
| 1523 | /// |
| 1524 | /// `to` is exclusive and may exceed `1440`, which is how a span that runs past |
| 1525 | /// midnight is said without a second date: `Span::new(1320, 1560)` is 22:00 to |
| 1526 | /// 02:00. |
| 1527 | |
| 1528 | |
| 1529 | from: u16, |
| 1530 | to: u16, |
| 1531 | |
| 1532 | |
| 1533 | |
| 1534 | /// Midnight to midnight, the ordinary day. |
| 1535 | pub const DAY: Self = Self ; |
| 1536 | |
| 1537 | /// A span, clamped to a sane one. |
| 1538 | /// |
| 1539 | /// An empty or backwards span is a caller bug that should not cost a |
| 1540 | /// renderer a division by zero, so `to` is forced at least one minute past |
| 1541 | /// `from` rather than returning an error nobody can act on. Same reasoning |
| 1542 | /// as [`Share::percent`], which clamps rather than refuses. |
| 1543 | |
| 1544 | pub const |
| 1545 | Self |
| 1546 | from, |
| 1547 | to: if to > from else , |
| 1548 | |
| 1549 | |
| 1550 | |
| 1551 | /// The first minute on the axis. |
| 1552 | |
| 1553 | pub const |
| 1554 | self.from |
| 1555 | |
| 1556 | |
| 1557 | /// One past the last minute on the axis. |
| 1558 | |
| 1559 | pub const |
| 1560 | self.to |
| 1561 | |
| 1562 | |
| 1563 | /// How many minutes the axis covers. Never zero. |
| 1564 | |
| 1565 | pub const |
| 1566 | self.to - self.from |
| 1567 | |
| 1568 | |
| 1569 | /// Whether a minute falls on this axis. |
| 1570 | |
| 1571 | pub const |
| 1572 | minute >= self.from && minute < self.to |
| 1573 | |
| 1574 | |
| 1575 | |
| 1576 | |
| 1577 | |
| 1578 | SelfDAY |
| 1579 | |
| 1580 | |
| 1581 | |
| 1582 | /// Where a thing sits on a [`Track`], and for how long. |
| 1583 | /// |
| 1584 | /// The one fact a list cannot carry and the whole reason this primitive exists. |
| 1585 | /// A list says what order things come in; a track says a thing starts 135 |
| 1586 | /// minutes along and lasts 45, which is a different claim and not derivable |
| 1587 | /// from the first. |
| 1588 | |
| 1589 | |
| 1590 | at: u16, |
| 1591 | minutes: u16, |
| 1592 | |
| 1593 | |
| 1594 | |
| 1595 | /// A placement, clamped to a drawable one. |
| 1596 | /// |
| 1597 | /// Zero minutes becomes one for the same reason [`Span::new`] clamps: a |
| 1598 | /// zero-height thing is invisible rather than expressive, and every |
| 1599 | /// renderer would need its own guard. |
| 1600 | |
| 1601 | pub const |
| 1602 | Self |
| 1603 | at, |
| 1604 | minutes: if minutes == 0 else , |
| 1605 | |
| 1606 | |
| 1607 | |
| 1608 | /// Minutes from the start of the day, matching [`Span`]'s origin. |
| 1609 | |
| 1610 | pub const |
| 1611 | self.at |
| 1612 | |
| 1613 | |
| 1614 | /// How long it lasts. Never zero. |
| 1615 | |
| 1616 | pub const |
| 1617 | self.minutes |
| 1618 | |
| 1619 | |
| 1620 | /// One past its last minute. |
| 1621 | |
| 1622 | pub const |
| 1623 | self.at + self.minutes |
| 1624 | |
| 1625 | |
| 1626 | /// Whether two placements cover any of the same time. |
| 1627 | /// |
| 1628 | /// Geometry, and deliberately not a described field. Whether an overlap is |
| 1629 | /// a *conflict* is the app's judgment -- a meeting inside a block of free |
| 1630 | /// time overlaps and is fine -- and that judgment travels the way every |
| 1631 | /// other judgment does, as a [`Tone`] on the thing itself. What a renderer |
| 1632 | /// needs in order to lay two things side by side instead of on top of each |
| 1633 | /// other is this, and it can compute it. |
| 1634 | /// |
| 1635 | /// The alternative was a `conflicts: bool` on each entry, which is state |
| 1636 | /// that can disagree with the times beside it. Two sources for one fact is |
| 1637 | /// how a screen starts rendering a conflict badge on a thing that no longer |
| 1638 | /// conflicts. |
| 1639 | |
| 1640 | pub const |
| 1641 | self.at < other.end && other.at < self.end |
| 1642 | |
| 1643 | |
| 1644 | |
| 1645 | /// A time axis: things placed by when they happen, rather than flowed. |
| 1646 | /// |
| 1647 | /// # Why this is a primitive |
| 1648 | /// |
| 1649 | /// This crate refused to name it until 2026-08-15, on the argument that a |
| 1650 | /// description expressive enough to draw a timeline is a component library |
| 1651 | /// wearing a description's name. The refusal is withdrawn, and it is worth |
| 1652 | /// being precise about what was wrong with it, because the reasoning it used |
| 1653 | /// applies to real cases and should not be discarded with it. |
| 1654 | /// |
| 1655 | /// What a timeline needs that a [`List`](Region::Pane) does not is **one** |
| 1656 | /// thing: placement. Where a thing sits is a fact about the thing, the way a |
| 1657 | /// row's primary text is, and it is not derivable from order. Everything else a |
| 1658 | /// day view draws -- the labels, the gridlines, the item bodies, the tones -- |
| 1659 | /// is furniture this vocabulary already names. Measured against goingson's |
| 1660 | /// `day-planning-render.js`, the only members it needed and could not get were |
| 1661 | /// `at` and `minutes`. |
| 1662 | /// |
| 1663 | /// So the timeline was never a component library's worth of vocabulary. It was |
| 1664 | /// two integers, and the refusal was priced as though it were the whole widget. |
| 1665 | /// The test that matters is not "does this shape look complicated" but "how |
| 1666 | /// many members does it actually add, and are they facts or presentation". |
| 1667 | /// Slot heights, gridline colour, how overlaps stack and which hour scrolls |
| 1668 | /// into view on open are all presentation and all stay the renderer's, which is |
| 1669 | /// why they are absent here. |
| 1670 | /// |
| 1671 | /// # What it does not carry |
| 1672 | /// |
| 1673 | /// No pixel measure, no scroll offset, no drag affordance. A renderer draws the |
| 1674 | /// span at whatever density its host uses; `makeover-geometry` owns that the |
| 1675 | /// way it owns everything else measured in pixels. |
| 1676 | |
| 1677 | |
| 1678 | /// The window the axis covers. |
| 1679 | pub span: Span, |
| 1680 | /// The granularity a thing can be placed on, in minutes. |
| 1681 | /// |
| 1682 | /// goingson's day view is 15, giving 96 slots across a day. A renderer uses |
| 1683 | /// it to decide where gridlines fall and what a drop lands on; it does not |
| 1684 | /// constrain [`Placement`], because data arriving from a calendar does not |
| 1685 | /// respect anyone's grid. |
| 1686 | pub slot: u16, |
| 1687 | /// How often the axis labels itself, in minutes. |
| 1688 | /// |
| 1689 | /// 60 gives an hourly ruler over a 15-minute grid, which is the common |
| 1690 | /// shape and the reason this is separate from `slot`. Zero means an |
| 1691 | /// unlabelled axis. |
| 1692 | pub tick: u16, |
| 1693 | |
| 1694 | |
| 1695 | |
| 1696 | /// An ordinary day: midnight to midnight, quarter-hour slots, hourly ticks. |
| 1697 | pub const DAY: Self = Self |
| 1698 | span: DAY, |
| 1699 | slot: 15, |
| 1700 | tick: 60, |
| 1701 | ; |
| 1702 | |
| 1703 | /// A track over `span`, with the day's usual granularity. |
| 1704 | |
| 1705 | pub const |
| 1706 | Self |
| 1707 | span, |
| 1708 | slot: 15, |
| 1709 | tick: 60, |
| 1710 | |
| 1711 | |
| 1712 | |
| 1713 | /// How many slots the axis holds. |
| 1714 | /// |
| 1715 | /// Rounded up, so a span that does not divide evenly by `slot` still has a |
| 1716 | /// slot covering its tail rather than dropping it. Never zero: `slot` of 0 |
| 1717 | /// reads as one slot spanning the whole axis rather than a division by |
| 1718 | /// zero, since a renderer asking this question has already committed to |
| 1719 | /// drawing something. |
| 1720 | |
| 1721 | pub const |
| 1722 | if self.slot == 0 |
| 1723 | 1 |
| 1724 | else |
| 1725 | self.span.minutes.div_ceil |
| 1726 | |
| 1727 | |
| 1728 | |
| 1729 | /// Where a placement sits on the axis, as a fraction from 0.0 to 1.0. |
| 1730 | /// |
| 1731 | /// The one calculation every renderer would otherwise write itself, and the |
| 1732 | /// place the three would drift apart. Clamped, so a placement outside the |
| 1733 | /// span draws at the edge rather than off it -- an event running past |
| 1734 | /// midnight is a real thing and truncating it is better than either |
| 1735 | /// panicking or drawing it somewhere impossible. |
| 1736 | |
| 1737 | |
| 1738 | let span = f32from; |
| 1739 | let offset = f32from; |
| 1740 | .clamp |
| 1741 | |
| 1742 | |
| 1743 | |
| 1744 | |
| 1745 | |
| 1746 | SelfDAY |
| 1747 | |
| 1748 | |
| 1749 | |
| 1750 | |
| 1751 | |
| 1752 | /// What the control says. |
| 1753 | pub label: &'a str, |
| 1754 | /// The key that reaches it where a host has keys. |
| 1755 | /// |
| 1756 | /// The one member written for a terminal before there was one. A webview |
| 1757 | /// hangs it off `accesskey` or ignores it; a terminal has nothing else to |
| 1758 | /// offer, so this is the whole of how a control is reached there. |
| 1759 | pub key: , |
| 1760 | /// What pressing it means. [`Tone::Danger`] is the destructive one. |
| 1761 | pub tone: Tone, |
| 1762 | /// Disabled, or nothing said. |
| 1763 | /// |
| 1764 | /// [`State::Disabled`] is what changes what a renderer may do: see |
| 1765 | /// [`State::suppresses_interaction`], which is what says a disabled control |
| 1766 | /// is drawn and not reachable. It has been the only member since 0.19.0, |
| 1767 | /// and a control's focus is not sayable here at all — see the crate header, |
| 1768 | /// "Reach, focus and the focus ring". |
| 1769 | pub state: , |
| 1770 | |
| 1771 | |
| 1772 | |
| 1773 | /// An ordinary control, reachable, with no key. |
| 1774 | |
| 1775 | pub const |
| 1776 | Self |
| 1777 | label, |
| 1778 | key: None, |
| 1779 | tone: Neutral, |
| 1780 | state: None, |
| 1781 | |
| 1782 | |
| 1783 | |
| 1784 | /// The key that reaches it. |
| 1785 | |
| 1786 | pub const |
| 1787 | self.key = Some; |
| 1788 | self |
| 1789 | |
| 1790 | |
| 1791 | /// What pressing it means. |
| 1792 | |
| 1793 | pub const |
| 1794 | self.tone = tone; |
| 1795 | self |
| 1796 | |
| 1797 | |
| 1798 | /// Focus, or disabled. |
| 1799 | |
| 1800 | pub const |
| 1801 | self.state = Some; |
| 1802 | self |
| 1803 | |
| 1804 | |
| 1805 | /// Whether the control is drawn and does not answer. |
| 1806 | |
| 1807 | |
| 1808 | self.state.is_some_and |
| 1809 | |
| 1810 | |
| 1811 | |
| 1812 | /// A named part of a screen. |
| 1813 | /// |
| 1814 | /// The thing `makeover-geometry` deliberately does not name: it names the space |
| 1815 | /// *between* things by relationship, and nothing named the things. Six named |
| 1816 | /// members, taken from what the two webview apps actually use, plus |
| 1817 | /// [`Region::Bespoke`] for the parts no description should reach. Both apps' |
| 1818 | /// `layout.css` currently names exactly two things, `.raised` and `.well`, so |
| 1819 | /// this layer is absent rather than divergent, which makes it the cheapest of |
| 1820 | /// the schemas to add and the easiest to over-build. |
| 1821 | /// |
| 1822 | /// `#[non_exhaustive]` arrives with [`Region::Widget`], the pairing [`RowPart`] |
| 1823 | /// made at 0.9.0 and [`Readiness`] at 0.12.0, and for the same reason: the |
| 1824 | /// member after this one should not be a lockstep event across three renderers. |
| 1825 | |
| 1826 | |
| 1827 | |
| 1828 | /// A full-width strip with a title slot and an actions cluster, either of |
| 1829 | /// which may be empty. goingson's `.page-header`, Balanced Breakfast's |
| 1830 | /// `.header` and `.detail-header` are all this, differing only in which |
| 1831 | /// slots they fill. |
| 1832 | Band, |
| 1833 | /// A persistent column beside the content, holding navigation. |
| 1834 | Sidebar, |
| 1835 | /// A region of content with its own scroll. |
| 1836 | Pane, |
| 1837 | /// Two panes side by side, where the left chooses what the right shows. |
| 1838 | Split, |
| 1839 | /// A set of panes, one visible at a time, with a [`Selector::Tabs`] above. |
| 1840 | TabGroup, |
| 1841 | /// Content over a scrim, taking input until dismissed. |
| 1842 | Modal, |
| 1843 | /// A region this crate names the *place* of and nothing else. The app owns |
| 1844 | /// what goes in it. |
| 1845 | /// |
| 1846 | /// The escape hatch, and the thing that keeps the description honest about |
| 1847 | /// its own limits. A day-plan timeline, a kanban board, a calendar and the |
| 1848 | /// paint interaction over the timeline are not describable here and are not |
| 1849 | /// going to become describable: a description expressive enough to produce |
| 1850 | /// a timeline is a widget library wearing a description's name. |
| 1851 | /// |
| 1852 | /// But a screen containing one still has to be a screen. Without this |
| 1853 | /// member the description covers only the boring screens, and the four that |
| 1854 | /// make goingson worth using would need a second, undescribed path beside |
| 1855 | /// the router. Two paths is how the vocabulary starts drifting from the app |
| 1856 | /// again, which is the exact failure this crate exists to end. |
| 1857 | /// |
| 1858 | /// So the description says "a thing called `day-plan` goes here" and stops. |
| 1859 | /// The name is opaque: this crate never interprets it, and no renderer is |
| 1860 | /// expected to know what it means beyond handing the space over. |
| 1861 | Bespoke |
| 1862 | /// What the app calls it. Never interpreted here. |
| 1863 | name: &'a str, |
| 1864 | , |
| 1865 | /// A named assembly of things the vocabulary already says. |
| 1866 | /// |
| 1867 | /// The third tier, between a primitive and [`Bespoke`](Self::Bespoke). |
| 1868 | /// Stated by Max 2026-08-12 answering the carousel: "something in between a |
| 1869 | /// primitive and a bespoke interface, like a widget, which is just an |
| 1870 | /// assembly of primitives." Full note: wiki `widget-tier`. |
| 1871 | /// |
| 1872 | /// # What separates it from the two members either side |
| 1873 | /// |
| 1874 | /// A primitive is a thing every renderer draws from scratch, and the test |
| 1875 | /// it has to pass is that every host has an honest answer. A carousel fails |
| 1876 | /// that test — a terminal has no carousel — which is the same refusal |
| 1877 | /// `Node::Html` got and is why the carousel sat unsayable for months. |
| 1878 | /// |
| 1879 | /// [`Bespoke`](Self::Bespoke) fails it from the other side. Bespoke is for |
| 1880 | /// what one app owns and nobody will build twice, and it carries *no* |
| 1881 | /// contents: the description names the place and stops. A carousel is |
| 1882 | /// furniture any app would have, and every part of it — an ordered set of |
| 1883 | /// frames, a position, prev and next, a strip of position indicators — is |
| 1884 | /// already sayable. Only the assembly had no name. |
| 1885 | /// |
| 1886 | /// So this member is the pair the other two are not: a name **and** |
| 1887 | /// contents. The contents are the assembly, in the region's own body, said |
| 1888 | /// in members that already exist. |
| 1889 | /// |
| 1890 | /// # Why the name does not have to be understood |
| 1891 | /// |
| 1892 | /// A renderer that recognises the name draws it the way its host does it: a |
| 1893 | /// carousel in a webview, a pager with a count in a terminal, a selector in |
| 1894 | /// egui. A renderer that does not recognise it walks the body, which is |
| 1895 | /// primitives all the way down and which it can already draw. |
| 1896 | /// |
| 1897 | /// That is what lets the widget set be **open** without every renderer |
| 1898 | /// knowing every widget. An unrecognised widget degrades to its assembly |
| 1899 | /// instead of failing, so a second or third party can name one without |
| 1900 | /// three renderers releasing in lockstep to accept it. Contrast |
| 1901 | /// [`Bespoke`](Self::Bespoke), which no renderer can degrade: there is |
| 1902 | /// nothing under it to fall back to. |
| 1903 | /// |
| 1904 | /// # What it does not do |
| 1905 | /// |
| 1906 | /// A widget is an assembly of things the vocabulary *already* says, so it |
| 1907 | /// buys no expressive power. Anything needing a member the vocabulary does |
| 1908 | /// not have is a finding about the vocabulary, and the answer to a finding |
| 1909 | /// is to add the member. A widget is never the way a primitive gets added |
| 1910 | /// by the back door. |
| 1911 | /// |
| 1912 | /// This used to say "it does not make a timeline describable, and the |
| 1913 | /// refusal in the crate header stands unchanged". The timeline is |
| 1914 | /// describable as of 2026-08-15 -- see [`Track`] -- and it got there the |
| 1915 | /// way the paragraph above says it should have: by adding the two members |
| 1916 | /// that were missing, not by dressing the screen up as an assembly. |
| 1917 | Widget |
| 1918 | /// What the assembly is called. This crate never interprets it, and a |
| 1919 | /// renderer is free not to know it. |
| 1920 | name: &'a str, |
| 1921 | , |
| 1922 | |
| 1923 | |
| 1924 | |
| 1925 | /// How the region sits on what is behind it. |
| 1926 | |
| 1927 | pub const |
| 1928 | match self |
| 1929 | SelfBand | SelfSidebar | SelfSplit | SelfTabGroup => Flat, |
| 1930 | // A pane is looked into, the same as a table body or a tag tree. |
| 1931 | SelfPane => Well, |
| 1932 | SelfModal => Raised, |
| 1933 | // Flat because it inherits: a bespoke region takes the depth of |
| 1934 | // whatever frames it. An app that wants its timeline in a well puts |
| 1935 | // it in a `Pane`, which composes rather than adding a knob here. |
| 1936 | // |
| 1937 | // A widget inherits for the same reason and it matters more here, |
| 1938 | // because a widget is drawn by whichever renderer recognises it. A |
| 1939 | // depth set here would be this crate deciding that a carousel is |
| 1940 | // raised on every host, which is the kind of value the deferral |
| 1941 | // rule exists to refuse. |
| 1942 | SelfBespoke | SelfWidget => Flat, |
| 1943 | |
| 1944 | |
| 1945 | |
| 1946 | /// Whether this crate can say anything about the region's contents. |
| 1947 | /// |
| 1948 | /// A renderer walks the description and hands every region it understands |
| 1949 | /// to the right drawing code. This is how it tells the two apart, and the |
| 1950 | /// reason it is a method rather than a `matches!` at each renderer: there |
| 1951 | /// is exactly one opaque member and there should stay exactly one. |
| 1952 | /// |
| 1953 | /// [`Widget`](Self::Widget) is described, and that is the whole of what |
| 1954 | /// separates it from [`Bespoke`](Self::Bespoke) here. Both carry a name |
| 1955 | /// this crate never interprets; only one of them carries contents under it. |
| 1956 | /// A renderer that does not recognise a widget's name still walks its body, |
| 1957 | /// so there is nothing for it to hand over and nothing it cannot draw. |
| 1958 | |
| 1959 | pub const |
| 1960 | !matches! |
| 1961 | |
| 1962 | |
| 1963 | /// The name an app gave this region, if it gave one. |
| 1964 | /// |
| 1965 | /// [`Bespoke`](Self::Bespoke) and [`Widget`](Self::Widget) are the two |
| 1966 | /// members that carry a name, for two different purposes: one says what the |
| 1967 | /// app will fill the space with, the other says what the assembly under it |
| 1968 | /// is called. A renderer dispatching on either wants the string without |
| 1969 | /// caring which member it came from, and writing that `matches!` at each |
| 1970 | /// renderer is how the two drift apart. |
| 1971 | |
| 1972 | pub const |
| 1973 | match self |
| 1974 | SelfBespoke | SelfWidget => Some, |
| 1975 | // Spelled out rather than a wildcard, so a member added later has |
| 1976 | // to answer whether it carries a name instead of inheriting `None` |
| 1977 | // by sitting under a `_`. |
| 1978 | SelfBand |
| 1979 | | SelfSidebar |
| 1980 | | SelfPane |
| 1981 | | SelfSplit |
| 1982 | | SelfTabGroup |
| 1983 | | SelfModal => None, |
| 1984 | |
| 1985 | |
| 1986 | |
| 1987 | |
| 1988 | /// How many of a region's children are visible at once. |
| 1989 | /// |
| 1990 | /// `4dcd241b`. Three findings turned out to be one sentence the vocabulary |
| 1991 | /// could not say: *this region holds several children and shows some of them, |
| 1992 | /// and the reader can change which.* [`Region::TabGroup`] existed with nothing |
| 1993 | /// saying which tab was open, a carousel had nothing saying which frame was up, |
| 1994 | /// and a disclosure had nothing saying whether its one child was showing at all. |
| 1995 | /// |
| 1996 | /// Because the fact lived nowhere, a renderer had two moves: hardcode a widget |
| 1997 | /// name, or draw every child. That is what put per-widget code in renderers, and |
| 1998 | /// it was the missing member rather than the widget tier that put it there. |
| 1999 | /// |
| 2000 | /// # What is here and what is not |
| 2001 | /// |
| 2002 | /// The *kind*, and only the kind. Which child is currently up is the current |
| 2003 | /// answer, and a layer that defers every address does not hold the current |
| 2004 | /// answer either — the split [`Selector`] already makes, where this crate says |
| 2005 | /// what kind of chooser a thing is and the router says which option is picked. |
| 2006 | /// So a holder of regions carries the index and the per-child label beside this. |
| 2007 | /// |
| 2008 | /// # What a renderer does with it |
| 2009 | /// |
| 2010 | /// Derives its chrome, once, for every widget rather than per name: |
| 2011 | /// |
| 2012 | /// - Children carrying labels get a strip of the labels, the current one marked. |
| 2013 | /// - Children carrying none get previous, position, next. |
| 2014 | /// - [`AtMostOne`](Self::AtMostOne) over one child gets a summary line that |
| 2015 | /// opens. |
| 2016 | /// |
| 2017 | /// The name on [`Region::Widget`] survives as app vocabulary, for a renderer |
| 2018 | /// that wants to do something *special* with one, which is what it should have |
| 2019 | /// been from the start. |
| 2020 | /// |
| 2021 | /// Degradation runs the way it already did: a renderer ignoring this draws every |
| 2022 | /// child, which is more content rather than less. |
| 2023 | |
| 2024 | |
| 2025 | |
| 2026 | /// Every child, in order. What every region did before this existed. |
| 2027 | |
| 2028 | All, |
| 2029 | /// Exactly one. A carousel, a tab group. |
| 2030 | One, |
| 2031 | /// One, or none. A disclosure, which is closed until it is opened. |
| 2032 | AtMostOne, |
| 2033 | |
| 2034 | |
| 2035 | |
| 2036 | /// Whether the reader can change which child is up. |
| 2037 | /// |
| 2038 | /// The question every renderer's region arm asks before deriving any |
| 2039 | /// chrome, and a method rather than a `matches!` at each renderer for |
| 2040 | /// [`Region::name`]'s reason: three renderers writing the same comparison is |
| 2041 | /// how they come to disagree about a member added later. |
| 2042 | |
| 2043 | pub const |
| 2044 | !matches! |
| 2045 | |
| 2046 | |
| 2047 | /// Whether showing nothing is a legal state. |
| 2048 | /// |
| 2049 | /// True only for [`AtMostOne`](Self::AtMostOne). A renderer needs this to |
| 2050 | /// know whether its control closes as well as moves: a carousel's row moves |
| 2051 | /// between frames and never reaches empty, and a disclosure's summary line |
| 2052 | /// is the same control wearing its closed state. |
| 2053 | |
| 2054 | pub const |
| 2055 | matches! |
| 2056 | |
| 2057 | |
| 2058 | |
| 2059 | /// How much of the width an arrangement's first region takes. |
| 2060 | /// |
| 2061 | /// `e0fd485e`. Nothing said how much room a region got, so every renderer |
| 2062 | /// invented its own number and two hosts showing one screen disagreed about |
| 2063 | /// its proportions. A webview never noticed, because the stylesheet answered |
| 2064 | /// once for every consumer; a terminal has no stylesheet to inherit from, so |
| 2065 | /// `quasi-tui` picked 24 columns for a sidebar and 40% for a list pane and |
| 2066 | /// neither had anything behind it. |
| 2067 | /// |
| 2068 | /// # A proportion, never a unit |
| 2069 | /// |
| 2070 | /// Held as a percentage, and that is the only form it comes in. A description |
| 2071 | /// carrying columns would be describing a terminal and one carrying pixels a |
| 2072 | /// webview, and the whole point is that both honour the same fact: a terminal |
| 2073 | /// resolves it against a column count, a webview writes it into a grid, and |
| 2074 | /// neither has to know what the other did. |
| 2075 | /// |
| 2076 | /// It is not [`makeover_geometry::Ratio`]'s job either, which was the first |
| 2077 | /// guess. Geometry is scales that answer the same for every screen and takes |
| 2078 | /// no input that would let a sidebar screen differ from a list-detail one. |
| 2079 | /// |
| 2080 | /// [`makeover_geometry::Ratio`]: https://docs.rs/makeover-geometry |
| 2081 | |
| 2082 | ; |
| 2083 | |
| 2084 | |
| 2085 | /// What a sidebar takes, when nobody says otherwise. |
| 2086 | /// |
| 2087 | /// A quarter. `quasi-tui` drew 24 columns, which is a quarter of a |
| 2088 | /// 96-column terminal and about a fifth of a wide one; a quarter is that |
| 2089 | /// number said in the form a webview can honour too. |
| 2090 | pub const SIDEBAR: Self = Self; |
| 2091 | |
| 2092 | /// What the list side of a list-detail takes, when nobody says otherwise. |
| 2093 | /// |
| 2094 | /// `quasi-tui`'s 40%, which was already a proportion and is the one number |
| 2095 | /// this member did not have to invent. |
| 2096 | pub const LIST: Self = Self; |
| 2097 | |
| 2098 | /// A share of the width, as a percentage. |
| 2099 | /// |
| 2100 | /// Clamped to 5..=95 rather than refused. A description that asked for a |
| 2101 | /// region of nothing is a bug in the app, and a renderer drawing a region |
| 2102 | /// zero cells wide reports it as a region that vanished, which is the |
| 2103 | /// hardest kind of bug to find from what is on the screen. |
| 2104 | |
| 2105 | pub const |
| 2106 | Self |
| 2107 | 5 |
| 2108 | else if percent > 95 |
| 2109 | 95 |
| 2110 | else |
| 2111 | percent |
| 2112 | |
| 2113 | |
| 2114 | |
| 2115 | /// The share as a percentage. |
| 2116 | |
| 2117 | pub const |
| 2118 | self.0 |
| 2119 | |
| 2120 | |
| 2121 | /// This share of a width, rounded to the nearest whole unit. |
| 2122 | /// |
| 2123 | /// What a terminal calls to turn the proportion into columns. At least one, |
| 2124 | /// because a region the description named should be visible: a screen |
| 2125 | /// 3 columns wide is unusable either way, and a sidebar that is there is a |
| 2126 | /// truer picture of the description than a sidebar that is not. |
| 2127 | |
| 2128 | pub const |
| 2129 | let taken = .div_ceil; |
| 2130 | if taken == 0 else |
| 2131 | |
| 2132 | |
| 2133 | |
| 2134 | /// How a screen is laid out. |
| 2135 | /// |
| 2136 | /// Two, and the second is not a variant of the first. goingson is list-detail, |
| 2137 | /// Balanced Breakfast is sidebar plus content, and neither app has a third. |
| 2138 | /// The tab group is a modifier rather than a member, because goingson uses it |
| 2139 | /// *inside* the same content region rather than instead of one. |
| 2140 | /// |
| 2141 | /// This exists at all because the router has to be able to express a screen |
| 2142 | /// rather than only a control. Discovering the arrangement layer missing after |
| 2143 | /// the renderers exist is a redesign; naming two now is a morning. |
| 2144 | /// |
| 2145 | /// # Why the share rides here |
| 2146 | /// |
| 2147 | /// `e0fd485e`. A share is per-arrangement: how much a sidebar takes and how |
| 2148 | /// much a list side takes are different questions, and this enum is the only |
| 2149 | /// thing that knows which one is being asked. Geometry would have had to invent |
| 2150 | /// a channel to be told. |
| 2151 | /// |
| 2152 | /// [`list_detail`](Self::list_detail) and |
| 2153 | /// [`sidebar_content`](Self::sidebar_content) build these with the default |
| 2154 | /// shares, so a screen that has no opinion does not have to have one. |
| 2155 | |
| 2156 | |
| 2157 | /// A list that chooses what the detail beside it shows. |
| 2158 | ListDetail |
| 2159 | /// Whether the detail side is a [`Region::TabGroup`]. |
| 2160 | tabbed: bool, |
| 2161 | /// How much of the width the list side takes. |
| 2162 | share: Share, |
| 2163 | , |
| 2164 | /// Navigation down the side, content filling the rest. |
| 2165 | SidebarContent |
| 2166 | /// How much of the width the sidebar takes. |
| 2167 | share: Share, |
| 2168 | , |
| 2169 | |
| 2170 | |
| 2171 | |
| 2172 | /// A list and a detail beside it, at the default share. |
| 2173 | |
| 2174 | pub const |
| 2175 | SelfListDetail |
| 2176 | tabbed, |
| 2177 | share: LIST, |
| 2178 | |
| 2179 | |
| 2180 | |
| 2181 | /// A sidebar and content beside it, at the default share. |
| 2182 | |
| 2183 | pub const |
| 2184 | SelfSidebarContent |
| 2185 | share: SIDEBAR, |
| 2186 | |
| 2187 | |
| 2188 | |
| 2189 | /// How much of the width the first region takes. |
| 2190 | |
| 2191 | pub const |
| 2192 | match self |
| 2193 | SelfListDetail | SelfSidebarContent => share, |
| 2194 | |
| 2195 | |
| 2196 | |
| 2197 | /// The same arrangement, at this share. |
| 2198 | |
| 2199 | pub const |
| 2200 | match self |
| 2201 | SelfListDetail => SelfListDetail , |
| 2202 | SelfSidebarContent => SelfSidebarContent , |
| 2203 | |
| 2204 | |
| 2205 | |
| 2206 | |
| 2207 | /// How wide the content of a whole screen runs. |
| 2208 | /// |
| 2209 | /// `0eccff0d`, and [`Share`]'s sibling one level up: that one says how a |
| 2210 | /// screen's width is divided between regions, this says how much of the window |
| 2211 | /// the screen uses in the first place. Both are the description's, which is |
| 2212 | /// what answering the two together settled. |
| 2213 | /// |
| 2214 | /// Measured in the MNW server, where 69 of 72 templates carry exactly one of |
| 2215 | /// three mutually exclusive classes and the choice is per screen. GoingsOn |
| 2216 | /// reaches for `max-width` 56 times and Balanced Breakfast 12, neither with a |
| 2217 | /// token for it, so three apps were solving one thing by hand. |
| 2218 | /// |
| 2219 | /// # Named for the measure, not for MNW's classes |
| 2220 | /// |
| 2221 | /// A renderer that is not a browser has to answer this too, and `padded-page` |
| 2222 | /// tells a terminal nothing. The three say how wide the text runs, which is a |
| 2223 | /// question every renderer can answer: a webview with a `max-width`, a terminal |
| 2224 | /// with gutters, an immediate-mode frame with its own width. |
| 2225 | /// |
| 2226 | /// `#[non_exhaustive]` for [`Fill`]'s reason. The set is closed today because |
| 2227 | /// the measurement found three, and a fourth arriving should not be a lockstep |
| 2228 | /// release across nine repos. |
| 2229 | |
| 2230 | |
| 2231 | |
| 2232 | /// The whole width, with gutters. The default, and 53 of the 69. |
| 2233 | /// |
| 2234 | /// What a dashboard, a table and a settings screen want: the content is |
| 2235 | /// wide because the content *is* wide, and constraining it would waste the |
| 2236 | /// window. |
| 2237 | |
| 2238 | Wide, |
| 2239 | /// Capped at a comfortable page width, centred. 13 of the 69. |
| 2240 | /// |
| 2241 | /// A form, a sign-in, a purchase. Content that does not get better by |
| 2242 | /// getting wider, but is not prose either. |
| 2243 | Contained, |
| 2244 | /// Capped at a line length that reads well. 3 of the 69. |
| 2245 | /// |
| 2246 | /// Prose. The narrowest of the three, and the one with a reason outside |
| 2247 | /// taste: a line of text past roughly 75 characters costs the reader the |
| 2248 | /// return sweep. |
| 2249 | Reading, |
| 2250 | |
| 2251 | |
| 2252 | |
| 2253 | /// A stable name, for a renderer that needs to spell it. |
| 2254 | /// |
| 2255 | /// Here rather than in each renderer for [`Sort::as_str`]'s reason: three |
| 2256 | /// renderers spelling one enum is three chances to spell it differently. |
| 2257 | |
| 2258 | pub const |
| 2259 | match self |
| 2260 | SelfWide => "wide", |
| 2261 | SelfContained => "contained", |
| 2262 | SelfReading => "reading", |
| 2263 | |
| 2264 | |
| 2265 | |
| 2266 | |
| 2267 | /// What kind of value a form field takes. |
| 2268 | /// |
| 2269 | /// The union of the two vocabularies that diverged, which is what triggered |
| 2270 | /// this crate. They have since converged on their own: both apps now have a |
| 2271 | /// `renderFormField` emitting the same anatomy, and what is left differing is |
| 2272 | /// the kind set, the error shape, and whether the return is a string or a node. |
| 2273 | /// |
| 2274 | /// Validation is deliberately absent. Neither app has a shared story (goingson |
| 2275 | /// validates after collecting the form data, with per-field transform hooks; |
| 2276 | /// Balanced Breakfast has `required` and nothing else), and a schema that |
| 2277 | /// describes fields but not constraints acquires a constraint layer per app, |
| 2278 | /// which is exactly how the current divergence started. Naming it absent is a |
| 2279 | /// decision; leaving it unmentioned would not be. |
| 2280 | /// `#[non_exhaustive]` for the reason [`Fill`] is: renderers match on this and |
| 2281 | /// the set keeps growing, so growth must not be a lockstep event. Email, Url |
| 2282 | /// and Tel arriving in 0.5.0 is the second growth in two releases. |
| 2283 | |
| 2284 | |
| 2285 | |
| 2286 | /// A single line of text. |
| 2287 | Text, |
| 2288 | /// A single line of text that must never be echoed, logged or round-tripped |
| 2289 | /// through anything that might persist it. |
| 2290 | Secret, |
| 2291 | /// A number. |
| 2292 | Number, |
| 2293 | /// An email address. |
| 2294 | /// |
| 2295 | /// Distinct from [`Text`](Self::Text) because the distinction is not |
| 2296 | /// decoration: a webview renderer emits `type="email"`, which on a touch |
| 2297 | /// device changes the keyboard that appears and turns on the platform's own |
| 2298 | /// validation. goingson ships to iOS, so collapsing this into text costs a |
| 2299 | /// keyboard with no `@` on it. |
| 2300 | /// |
| 2301 | /// Added 0.5.0, from goingson's contact form. |
| 2302 | Email, |
| 2303 | /// A URL. Same reasoning as [`Email`](Self::Email). |
| 2304 | /// |
| 2305 | /// Added 0.5.0, from goingson's contact-social and contact-feed forms. |
| 2306 | Url, |
| 2307 | /// A telephone number. Same reasoning as [`Email`](Self::Email), and the |
| 2308 | /// clearest case of it: the keyboard is a numeric pad rather than letters. |
| 2309 | /// |
| 2310 | /// Added 0.5.0, from goingson's contact-phone form. |
| 2311 | Tel, |
| 2312 | /// A calendar day, with no time of day in it. |
| 2313 | /// |
| 2314 | /// [`Email`](Self::Email)'s argument, and it carries further: a webview |
| 2315 | /// emits `type="date"`, which is a native picker, the platform's own |
| 2316 | /// validation, and on a touch device the date keyboard. Described as |
| 2317 | /// [`Text`](Self::Text) with a hint reading "YYYY-MM-DD", all three are |
| 2318 | /// lost and the hint is doing the platform's job in prose. |
| 2319 | /// |
| 2320 | /// The membership test passes on every host without stretching: a webview |
| 2321 | /// and a Tauri app emit the input, egui has a date picker, a terminal |
| 2322 | /// prompts for a day and can validate it, a CLI takes an argument. |
| 2323 | /// |
| 2324 | /// # The value is ISO 8601, `YYYY-MM-DD` |
| 2325 | /// |
| 2326 | /// Named here rather than left to each host, because a host that picks |
| 2327 | /// differently sends a server something it parses differently, and the |
| 2328 | /// failure is silent and per-host. It is `<input type="date">`'s own wire |
| 2329 | /// format, so the webview renderer owes nothing to honour it and the other |
| 2330 | /// hosts have one spelling to meet. [`DATE_FORMAT`] is the constant, and a |
| 2331 | /// test asserts this doc and that constant agree. |
| 2332 | /// |
| 2333 | /// Added 0.15.0, from the MNW server's git access-token expiry |
| 2334 | /// (`user_ssh_keys_tab.html`) and six further sites across the server and |
| 2335 | /// goingson. |
| 2336 | Date, |
| 2337 | /// A calendar day and a time of day together. |
| 2338 | /// |
| 2339 | /// Apart from [`Date`](Self::Date) because the question is different rather |
| 2340 | /// than more precise: "which day does this expire" and "at what moment does |
| 2341 | /// this publish" are asked by different screens and answered by different |
| 2342 | /// controls. A webview emits `type="datetime-local"` for one and |
| 2343 | /// `type="date"` for the other, and a host that collapsed them would ask |
| 2344 | /// half the tree for a precision it does not want. |
| 2345 | /// |
| 2346 | /// Both arrived together on measurement rather than on symmetry: 13 sites |
| 2347 | /// of each across the MNW server and goingson, and **zero** of `time`, |
| 2348 | /// `month` or `week`, which is why those are not here. A member added for a |
| 2349 | /// case nobody has is a member designed against nothing, which is |
| 2350 | /// [`File`](Self::File)'s reasoning about `accept` applied to a whole |
| 2351 | /// member. |
| 2352 | /// |
| 2353 | /// # The value is `YYYY-MM-DDTHH:MM`, local, with no zone |
| 2354 | /// |
| 2355 | /// `<input type="datetime-local">`'s own format, and the "local" is the |
| 2356 | /// load-bearing half: the value carries no offset and no `Z`, so the moment |
| 2357 | /// it names is only fixed once something supplies a zone. That is the app's |
| 2358 | /// business and not the description's. Seconds are absent, which is the |
| 2359 | /// browser's own default and is left as the rule rather than restated as a |
| 2360 | /// constraint. [`DATETIME_FORMAT`] is the constant. |
| 2361 | /// |
| 2362 | /// [`Field::min`] and [`Field::max`] already take "the host's own spelling |
| 2363 | /// of a bound", so a floor of *not in the past* needs nothing new here: it |
| 2364 | /// is a string in this same format. |
| 2365 | /// |
| 2366 | /// Added 0.15.0, from goingson's snooze picker and day planner and the MNW |
| 2367 | /// server's publish-at fields. |
| 2368 | DateTime, |
| 2369 | /// Several lines of text. |
| 2370 | Textarea, |
| 2371 | /// One of a fixed set, offered behind a control that shows one at a time. |
| 2372 | Select, |
| 2373 | /// One of a fixed set, with every option on screen at once. |
| 2374 | /// |
| 2375 | /// Not a presentation of [`Select`](Self::Select), which is the reading to |
| 2376 | /// resist: what differs is a property of the *question*. A choice that is |
| 2377 | /// consequential or irreversible has to be readable without opening |
| 2378 | /// anything, because a closed control shows one option and hides the rest, |
| 2379 | /// and the one it shows is whichever was current before the user had read |
| 2380 | /// the alternatives. audiofiles asks whether a library copies samples into |
| 2381 | /// its store or references them where they lie — which cannot be changed |
| 2382 | /// afterwards — and had already promoted that out of a checkbox by hand, |
| 2383 | /// with a comment giving this reason, before the description could say it. |
| 2384 | /// |
| 2385 | /// It was described here at 0.8.1 as "the one HTML input type this enum was |
| 2386 | /// missing", which was not true then and is not true now: `file` arrived at |
| 2387 | /// 0.11.0 and `date` and `datetime-local` at 0.15.0. Everything here is |
| 2388 | /// still an `<input type=...>`, a `<select>` or a `<textarea>`, and the way |
| 2389 | /// this enum grows is by a site being measured rather than by a list being |
| 2390 | /// completed, so "the last one" is not a claim it should make again. |
| 2391 | /// |
| 2392 | /// Added 0.8.1, from audiofiles' Add Library form. |
| 2393 | Radio, |
| 2394 | /// On or off. |
| 2395 | Checkbox, |
| 2396 | /// A file the user picks from wherever the host keeps files. |
| 2397 | /// |
| 2398 | /// Added 0.11.0, `844b5ae0`, from goingson's project-dashboard attachments |
| 2399 | /// column. It was filed as a router finding — a control whose destination is |
| 2400 | /// a host capability rather than an address — and splitting it is what made |
| 2401 | /// it two answers instead of one member satisfying neither. *Opening* a file |
| 2402 | /// is a one-way handoff and needs no new API. *Picking* one returns a value |
| 2403 | /// into a write, which is a form concern, which is this. |
| 2404 | /// |
| 2405 | /// The membership test passes on every host and not by a stretch: a Tauri |
| 2406 | /// app opens a native picker, a server renders `<input type="file">`, a |
| 2407 | /// terminal prompts for a path, a CLI takes an argument. That is closer to |
| 2408 | /// [`Email`](Self::Email), which exists because it changes the keyboard, |
| 2409 | /// than to anything bespoke. |
| 2410 | /// |
| 2411 | /// It carries no accepted-types list and no multiple flag, and that is |
| 2412 | /// measured rather than deferred: `accept` appears at zero sites in either |
| 2413 | /// app. A member added for a case nobody has is a member designed against |
| 2414 | /// nothing. |
| 2415 | File, |
| 2416 | /// Carried through the form and never shown. |
| 2417 | Hidden, |
| 2418 | |
| 2419 | |
| 2420 | /// The wire format a [`FieldKind::Date`] value takes: ISO 8601, `YYYY-MM-DD`. |
| 2421 | /// |
| 2422 | /// A constant rather than a sentence in a doc comment, because the reason to |
| 2423 | /// name the format at all is that a host picking its own would fail silently |
| 2424 | /// against a server parsing another. A host that cannot emit the native control |
| 2425 | /// still has one spelling to meet, and can say which one it meant. |
| 2426 | pub const DATE_FORMAT: &str = "%Y-%m-%d"; |
| 2427 | |
| 2428 | /// The wire format a [`FieldKind::DateTime`] value takes: `YYYY-MM-DDTHH:MM`, |
| 2429 | /// local, carrying no zone and no seconds. |
| 2430 | /// |
| 2431 | /// [`DATE_FORMAT`]'s sibling and there for its reason. The absent zone is a |
| 2432 | /// property of the value rather than an omission: the moment is not fixed until |
| 2433 | /// something outside the description supplies one. |
| 2434 | pub const DATETIME_FORMAT: &str = "%Y-%m-%dT%H:%M"; |
| 2435 | |
| 2436 | |
| 2437 | /// Whether the value the kind takes is a moment rather than a string. |
| 2438 | /// |
| 2439 | /// Named once here for the reason [`offers_options`](Self::offers_options) |
| 2440 | /// is: two kinds answer yes, and a host that has to parse or format a value |
| 2441 | /// needs to ask without spelling the pair out at each renderer. A third |
| 2442 | /// temporal kind should land here and nowhere else. |
| 2443 | /// |
| 2444 | /// The format each one takes is [`DATE_FORMAT`] and [`DATETIME_FORMAT`]. |
| 2445 | |
| 2446 | pub const |
| 2447 | matches! |
| 2448 | |
| 2449 | |
| 2450 | /// Whether the field is drawn at all. |
| 2451 | |
| 2452 | pub const |
| 2453 | !matches! |
| 2454 | |
| 2455 | |
| 2456 | /// Whether the value must be kept out of logs and diagnostics. |
| 2457 | |
| 2458 | pub const |
| 2459 | matches! |
| 2460 | |
| 2461 | |
| 2462 | /// Where the field's own label sits. |
| 2463 | /// |
| 2464 | /// A checkbox labels itself on the right of the box; everything else takes |
| 2465 | /// a label above. Both webview apps already do this and both special-case |
| 2466 | /// it inline, which is the tell that it belongs in the description. |
| 2467 | /// |
| 2468 | /// A [`Radio`](Self::Radio) is not one of them, and the near-miss is worth |
| 2469 | /// naming: its *options* each label themselves, but the field still asks a |
| 2470 | /// question above them, so the group takes a label like everything else. |
| 2471 | |
| 2472 | pub const |
| 2473 | matches! |
| 2474 | |
| 2475 | |
| 2476 | /// Whether the kind reads [`Field::options`]. |
| 2477 | /// |
| 2478 | /// Two kinds do, so the pair is named once here rather than spelled out at |
| 2479 | /// each renderer and again in [`Field::options`]' own doc, where "every |
| 2480 | /// kind but `Select`" was true for exactly one release. A third |
| 2481 | /// option-taking kind should land here and nowhere else. |
| 2482 | |
| 2483 | pub const |
| 2484 | matches! |
| 2485 | |
| 2486 | |
| 2487 | |
| 2488 | /// One option offered by a field [`FieldKind::offers_options`] accepts. |
| 2489 | /// |
| 2490 | /// Two strings, because the submitted value and the read label are different |
| 2491 | /// facts and every renderer that has tried to collapse them has had to |
| 2492 | /// un-collapse them later. `makeover-webview` invented this shape writing its |
| 2493 | /// form emitter and it is taken here unchanged; moving it down rather than |
| 2494 | /// re-deriving it is the point, since the second and third renderers were each |
| 2495 | /// going to arrive at a near-miss of it. |
| 2496 | |
| 2497 | |
| 2498 | /// What is submitted. |
| 2499 | pub value: &'a str, |
| 2500 | /// What is read. |
| 2501 | pub label: &'a str, |
| 2502 | |
| 2503 | |
| 2504 | |
| 2505 | /// An option whose submitted value is also its label. |
| 2506 | |
| 2507 | pub const |
| 2508 | Self |
| 2509 | value, |
| 2510 | label: value, |
| 2511 | |
| 2512 | |
| 2513 | |
| 2514 | |
| 2515 | /// One field of a form. |
| 2516 | /// |
| 2517 | /// Borrowed rather than owned: a description is built, read once by a renderer, |
| 2518 | /// and dropped. Nothing here outlives the screen it describes. |
| 2519 | /// |
| 2520 | /// # What it carries, and what it does not |
| 2521 | /// |
| 2522 | /// Stated here so the next renderer does not re-ask, which is what the first |
| 2523 | /// two both did. It carries everything a renderer needs to *draw* the field: |
| 2524 | /// its kind, what it is called, what it is asked for, its standing help, what |
| 2525 | /// is wrong with it now, whether it is compulsory, whether it hides behind a |
| 2526 | /// disclosure, its ghost text, and the options it offers. |
| 2527 | /// |
| 2528 | /// It does not carry the **current value**, and it is not going to. That is the |
| 2529 | /// one thing here that is genuinely renderer state: a webview reads it back out |
| 2530 | /// of the DOM, an immediate-mode renderer holds a `&mut` to the app's own field |
| 2531 | /// and writes through it, and a terminal keeps an edit buffer. A description |
| 2532 | /// that carried the value would have to carry a way to write it back, at which |
| 2533 | /// point it is a form model and no longer a description. |
| 2534 | /// |
| 2535 | /// **Constraints** are here and enforcement is not, which is one line rather |
| 2536 | /// than two. [`required`], [`max_length`], [`min`] and [`max`] are facts about |
| 2537 | /// the *question*, so a renderer can emit its host's idiom for each — an HTML |
| 2538 | /// attribute, a marked label, a clamped spinner — and the platform helps the |
| 2539 | /// user before anything is submitted. Deciding that a value is wrong stays with |
| 2540 | /// whoever validated, and [`error`] is that decision arriving back. |
| 2541 | /// |
| 2542 | /// The set stops before `pattern`, and stops there on both tests at once. A |
| 2543 | /// regex has an honest answer in a webview and none anywhere else: egui would |
| 2544 | /// have to run it per keystroke and decide what a half-typed value means, which |
| 2545 | /// is enforcement wearing description's clothes. And it is one site in goingson |
| 2546 | /// and none in Balanced Breakfast, against 8 and 1 for `maxlength`. Measured |
| 2547 | /// 2026-08-09, `2cbad3e2`. |
| 2548 | /// |
| 2549 | /// [`error`]: Field::error |
| 2550 | /// [`required`]: Field::required |
| 2551 | /// [`max_length`]: Field::max_length |
| 2552 | /// [`min`]: Field::min |
| 2553 | /// [`max`]: Field::max |
| 2554 | |
| 2555 | |
| 2556 | /// What kind of value it takes. |
| 2557 | pub kind: FieldKind, |
| 2558 | /// The name the value is submitted under. |
| 2559 | pub name: &'a str, |
| 2560 | /// What the user is asked for. |
| 2561 | pub label: &'a str, |
| 2562 | /// Standing help, shown whether or not anything is wrong. |
| 2563 | pub hint: , |
| 2564 | /// What is currently wrong with the value. |
| 2565 | pub error: , |
| 2566 | /// Ghost text shown while the field is empty. |
| 2567 | /// |
| 2568 | /// User-facing text, and it sits with `label` and `hint` rather than with |
| 2569 | /// the value because it is a property of the *question* and not of the |
| 2570 | /// answer. It lived renderer-side in `makeover-webview` until 0.8.0 for one |
| 2571 | /// reason and it was not a reading on where it belonged: adding a field to |
| 2572 | /// a published struct is a breaking change. |
| 2573 | /// |
| 2574 | /// Not a substitute for a label. A field labelled only by its placeholder |
| 2575 | /// loses its label the moment anything is typed, and no renderer here can |
| 2576 | /// make that not happen, so the description keeps both. |
| 2577 | pub placeholder: , |
| 2578 | /// The options offered, in the order they are offered. |
| 2579 | /// |
| 2580 | /// Empty for every kind [`FieldKind::offers_options`] rejects. A field |
| 2581 | /// described with no options is sayable on purpose: it is what an app with |
| 2582 | /// an unfinished-loading option list actually has, and a renderer showing |
| 2583 | /// an empty control says so on screen rather than in a log. |
| 2584 | /// |
| 2585 | /// Which option is *current* is not here. That is the value, and the value |
| 2586 | /// is renderer state. |
| 2587 | pub options: &'a [], |
| 2588 | /// Whether the form refuses to submit without it. |
| 2589 | pub required: bool, |
| 2590 | /// The longest the value may be, in characters. |
| 2591 | /// |
| 2592 | /// Added 0.11.0 with [`min`](Self::min) and [`max`](Self::max), joining |
| 2593 | /// [`required`](Self::required), which had been the only constraint here |
| 2594 | /// since before the crate wrote down that it carried none. |
| 2595 | pub max_length: , |
| 2596 | /// The lowest value accepted, as the host would write it. |
| 2597 | /// |
| 2598 | /// Text rather than a number, because the bound is only a number for some |
| 2599 | /// of the kinds that take one. goingson's own sites are `min="1"` on a |
| 2600 | /// duration and `min="2026-08-09T14:30"` on a datetime, and a numeric member |
| 2601 | /// could say the first and not the second. The [`kind`](Self::kind) already |
| 2602 | /// says how to read it, the same way it does for the value. |
| 2603 | pub min: , |
| 2604 | /// The highest value accepted, as the host would write it. See |
| 2605 | /// [`min`](Self::min). |
| 2606 | pub max: , |
| 2607 | /// Whether the field lives behind a "more options" disclosure. |
| 2608 | pub extended: bool, |
| 2609 | |
| 2610 | |
| 2611 | |
| 2612 | /// A plain required-nothing field of the given kind. |
| 2613 | |
| 2614 | pub const |
| 2615 | Self |
| 2616 | kind, |
| 2617 | name, |
| 2618 | label, |
| 2619 | hint: None, |
| 2620 | error: None, |
| 2621 | placeholder: None, |
| 2622 | options: &, |
| 2623 | required: false, |
| 2624 | max_length: None, |
| 2625 | min: None, |
| 2626 | max: None, |
| 2627 | extended: false, |
| 2628 | |
| 2629 | |
| 2630 | |
| 2631 | /// A select offering the given options. |
| 2632 | /// |
| 2633 | /// One of the two kinds under-described by [`Field::new`], so it gets a |
| 2634 | /// constructor rather than leaving every call site to remember that a |
| 2635 | /// select with an empty `options` renders as an empty select. |
| 2636 | |
| 2637 | pub const |
| 2638 | Selfoffering |
| 2639 | |
| 2640 | |
| 2641 | /// A radio group offering the given options. |
| 2642 | /// |
| 2643 | /// The other. Same hazard as [`select`](Self::select) and a worse one: a |
| 2644 | /// radio group with no options draws nothing at all, so a call site that |
| 2645 | /// forgot them has an empty rectangle rather than a visibly empty control. |
| 2646 | |
| 2647 | pub const |
| 2648 | Selfoffering |
| 2649 | |
| 2650 | |
| 2651 | /// The shared body of the two constructors that take options. |
| 2652 | /// |
| 2653 | /// Private, and keyed on the kind rather than exposed, because the two |
| 2654 | /// public names are the point: a call site says which question it is |
| 2655 | /// asking, not which flag it is setting. |
| 2656 | const |
| 2657 | kind: FieldKind, |
| 2658 | name: &'a str, |
| 2659 | label: &'a str, |
| 2660 | options: &'a [], |
| 2661 | |
| 2662 | Self |
| 2663 | options, |
| 2664 | ..Selfnew |
| 2665 | |
| 2666 | |
| 2667 | |
| 2668 | /// Whether the field is currently reporting a problem. |
| 2669 | /// |
| 2670 | /// Read this rather than testing `error.is_some()` at each renderer: the |
| 2671 | /// error state has to mark the field's whole group and not only the |
| 2672 | /// message, because a renderer with no descendant selectors (egui, a |
| 2673 | /// terminal) cannot find the group from the message. goingson already marks |
| 2674 | /// the group and Balanced Breakfast does not, so goingson's shape is the |
| 2675 | /// one taken here. |
| 2676 | |
| 2677 | pub const |
| 2678 | self.error.is_some |
| 2679 | |
| 2680 | |
| 2681 | |
| 2682 | /// How much room a column asks for. |
| 2683 | /// |
| 2684 | /// An intent, so the actual floor stays with `makeover-geometry`. goingson's |
| 2685 | /// task table spells these as `minmax(200px, 1fr)`, `140px` and content-sized; |
| 2686 | /// only the first three words of that survive deferral. |
| 2687 | /// `#[non_exhaustive]`, for the reason [`Fill`] and [`FieldKind`] are: a |
| 2688 | /// renderer matches on this and a vocabulary that grows must not break every |
| 2689 | /// renderer when it does. |
| 2690 | |
| 2691 | |
| 2692 | |
| 2693 | /// Takes what it needs and no more. |
| 2694 | Content, |
| 2695 | /// A fixed share, the same at every width. |
| 2696 | Fixed, |
| 2697 | /// Absorbs whatever is left over. |
| 2698 | Fill, |
| 2699 | |
| 2700 | |
| 2701 | /// What a column is worth when there is not room for all of them. |
| 2702 | /// |
| 2703 | /// Ordered: [`Priority::Optional`] drops first, [`Priority::Essential`] never |
| 2704 | /// drops. This replaces addressing columns by position, which is what both |
| 2705 | /// webview apps do today and is a live bug rather than only verbosity. goingson |
| 2706 | /// hides mobile columns with `nth-child(n+5)` against a seven-column table, so |
| 2707 | /// inserting a column silently hides the wrong one. |
| 2708 | /// `#[non_exhaustive]`, same reasoning as [`Width`]. Note the ordering is the |
| 2709 | /// whole point of the type, so a new tier has to be declared in its place in |
| 2710 | /// the sequence rather than appended. |
| 2711 | |
| 2712 | |
| 2713 | |
| 2714 | /// Dropped first. |
| 2715 | Optional, |
| 2716 | /// Dropped once the optional columns are gone. |
| 2717 | Secondary, |
| 2718 | /// Never dropped. Without it the row does not identify itself. |
| 2719 | Essential, |
| 2720 | |
| 2721 | |
| 2722 | /// One column of a table. |
| 2723 | /// |
| 2724 | /// Described once. The grid track, the cell order and the drop behaviour are |
| 2725 | /// all derived from this, rather than being three hand-written encodings that |
| 2726 | /// must agree and are never checked against each other. |
| 2727 | |
| 2728 | |
| 2729 | /// The heading, and the name the cell is addressed by. |
| 2730 | pub name: &'a str, |
| 2731 | /// How much room it asks for. |
| 2732 | pub width: Width, |
| 2733 | /// What it is worth when room runs out. |
| 2734 | pub priority: Priority, |
| 2735 | /// Whether the user can reorder the table by this column. |
| 2736 | /// |
| 2737 | /// `ce620871`. What reordering *calls* is not here — that is an address, and |
| 2738 | /// this crate names none — so a host pairs this with the route the way it |
| 2739 | /// pairs a row's parts with the row's activation. This says the affordance |
| 2740 | /// exists, which is what a renderer needs to draw a header a user can press |
| 2741 | /// rather than a heading they cannot. |
| 2742 | pub sortable: bool, |
| 2743 | /// Which way the table is ordered by this column, if it is. |
| 2744 | /// |
| 2745 | /// `None` on every column but the one in force. A renderer draws the caret |
| 2746 | /// from this and a webview sets `aria-sort`, which is why it is per column |
| 2747 | /// rather than a single fact on the table: the host idiom is a property of |
| 2748 | /// the header cell. |
| 2749 | /// |
| 2750 | /// Independent of [`sortable`](Self::sortable) rather than implied by it, |
| 2751 | /// because both combinations mean something. A column sorted and not |
| 2752 | /// sortable is a list ordered by a key the user cannot change, which is a |
| 2753 | /// real thing to describe and a caret worth drawing. |
| 2754 | pub sorted: , |
| 2755 | |
| 2756 | |
| 2757 | /// Which way a column is ordered. |
| 2758 | /// |
| 2759 | /// Two, because there is no third. "Unsorted" is [`Column::sorted`] being |
| 2760 | /// `None`, and folding it in here would be the same absence said twice. |
| 2761 | |
| 2762 | |
| 2763 | /// Smallest, earliest or first alphabetically at the top. |
| 2764 | Ascending, |
| 2765 | /// The other way. |
| 2766 | Descending, |
| 2767 | |
| 2768 | |
| 2769 | |
| 2770 | /// The other direction, for a header that flips when pressed. |
| 2771 | |
| 2772 | pub const |
| 2773 | match self |
| 2774 | SelfAscending => SelfDescending, |
| 2775 | SelfDescending => SelfAscending, |
| 2776 | |
| 2777 | |
| 2778 | |
| 2779 | /// What a webview writes into `aria-sort`. |
| 2780 | /// |
| 2781 | /// Named here rather than in the webview renderer because a terminal and an |
| 2782 | /// immediate-mode painter both want the same two words for a caret's label, |
| 2783 | /// and three renderers picking their own is the drift this crate ends. |
| 2784 | |
| 2785 | pub const |
| 2786 | match self |
| 2787 | SelfAscending => "ascending", |
| 2788 | SelfDescending => "descending", |
| 2789 | |
| 2790 | |
| 2791 | |
| 2792 | |
| 2793 | |
| 2794 | /// A column that absorbs slack and drops after the optional ones. |
| 2795 | |
| 2796 | pub const |
| 2797 | Self |
| 2798 | name, |
| 2799 | width: Fill, |
| 2800 | priority: Secondary, |
| 2801 | sortable: false, |
| 2802 | sorted: None, |
| 2803 | |
| 2804 | |
| 2805 | |
| 2806 | /// Whether this column survives at the given cutoff. |
| 2807 | /// |
| 2808 | /// A renderer narrows by raising the cutoff, and never by counting |
| 2809 | /// positions. |
| 2810 | |
| 2811 | pub const |
| 2812 | >= |
| 2813 | |
| 2814 | |
| 2815 | |
| 2816 | /// What a table cell holds. |
| 2817 | /// |
| 2818 | /// [`RowPart`] for tables, and it exists for the same reason: a part that |
| 2819 | /// carries a control is not text, and a renderer with one class for the whole |
| 2820 | /// cell paints it as though it were. `makeover-webview` emitted a single |
| 2821 | /// `.cell` until 0.25.0, so a button in a cell inherited the cell's content |
| 2822 | /// colour, which is the exact drift [`RowPart::intent`] prevents for rows and |
| 2823 | /// prevented for nothing here. |
| 2824 | /// |
| 2825 | /// Four members, and the count is what quasi's `Cell` was measured to carry: |
| 2826 | /// a value, tokens (33 cells across 22 server templates), actions (30 rows |
| 2827 | /// carrying a control, 5 beside a value) and a link (35 cells across 18 |
| 2828 | /// templates). Nothing was added past what something holds. |
| 2829 | /// |
| 2830 | /// `#[non_exhaustive]` for [`RowPart`]'s reason: growth here must not be a |
| 2831 | /// lockstep event across three renderers. |
| 2832 | /// |
| 2833 | /// # No hover-reveal |
| 2834 | /// |
| 2835 | /// [`RowPart`] carried a `revealed_on_hover` until 0.13.0 retired it, and this |
| 2836 | /// enum never gets one. A cell's actions are shown at rest in every consumer |
| 2837 | /// measured, and a member nothing uses is one three renderers owe an answer |
| 2838 | /// for. |
| 2839 | |
| 2840 | |
| 2841 | |
| 2842 | /// The cell's own text. |
| 2843 | Value, |
| 2844 | /// Small labelled things in the cell: a status badge, a chip. |
| 2845 | Tokens, |
| 2846 | /// Controls that act on what the row is about. |
| 2847 | Actions, |
| 2848 | /// The cell's value, where the value is itself a link. |
| 2849 | Link, |
| 2850 | |
| 2851 | |
| 2852 | |
| 2853 | /// The content intent the part takes. |
| 2854 | /// |
| 2855 | /// One part is text and three are not, so three answer with the intent |
| 2856 | /// inheriting already gives. That is [`RowPart::intent`]'s shape with the |
| 2857 | /// text side narrower: a cell's secondary and muted readings are the |
| 2858 | /// column's business, not the cell's. |
| 2859 | |
| 2860 | pub const |
| 2861 | match self |
| 2862 | SelfValue => "content", |
| 2863 | // A token carries its own tone, and a part-level intent underneath |
| 2864 | // it would fight the token sitting on it. |
| 2865 | SelfTokens => "content", |
| 2866 | // Actions carry controls rather than text. |
| 2867 | SelfActions => "content", |
| 2868 | // A link takes the action colour from the control it is, rather |
| 2869 | // than the cell's text colour from the cell it sits in. |
| 2870 | SelfLink => "content", |
| 2871 | |
| 2872 | |
| 2873 | |
| 2874 | |
| 2875 | |
| 2876 | |
| 2877 | use *; |
| 2878 | |
| 2879 | |
| 2880 | |
| 2881 | // Mutually exclusive is the test for one enum against several fields: a |
| 2882 | // region shows its content, or that it is coming, or that there is none, |
| 2883 | // or that it broke. Never two. |
| 2884 | assert!; |
| 2885 | for state in |
| 2886 | assert!; |
| 2887 | |
| 2888 | |
| 2889 | |
| 2890 | |
| 2891 | |
| 2892 | // The default is the behaviour every region had before this member |
| 2893 | // existed, which is what keeps it additive: a description written |
| 2894 | // against 0.22.0 says the same thing under 0.23.0. |
| 2895 | assert_eq!; |
| 2896 | assert!; |
| 2897 | |
| 2898 | |
| 2899 | |
| 2900 | |
| 2901 | // The two derived idioms differ in one respect and this is it. A |
| 2902 | // carousel's row moves between frames and never reaches empty; a |
| 2903 | // disclosure's summary line is the same control wearing its closed |
| 2904 | // state, so a renderer has to know which it is drawing. |
| 2905 | assert!; |
| 2906 | assert!; |
| 2907 | assert!; |
| 2908 | |
| 2909 | // Both are selective, though. Deriving chrome is one question and |
| 2910 | // whether that chrome closes is another. |
| 2911 | assert!; |
| 2912 | assert!; |
| 2913 | |
| 2914 | |
| 2915 | |
| 2916 | |
| 2917 | // An empty list is the normal state of a new install. Drawing it in a |
| 2918 | // danger tone reports a fault where there is none, and this is the one |
| 2919 | // place the distinction is carried. |
| 2920 | assert_eq!; |
| 2921 | assert_eq!; |
| 2922 | assert_eq!; |
| 2923 | |
| 2924 | |
| 2925 | |
| 2926 | |
| 2927 | // Both combinations mean something, which is why the two fields are |
| 2928 | // independent rather than one implying the other. A list ordered by a |
| 2929 | // key the user cannot change is a real thing with a caret worth drawing. |
| 2930 | let fixed = Column |
| 2931 | sorted: Some, |
| 2932 | ..new |
| 2933 | ; |
| 2934 | |
| 2935 | assert!; |
| 2936 | assert_eq!; |
| 2937 | |
| 2938 | let offered = Column |
| 2939 | sortable: true, |
| 2940 | ..new |
| 2941 | ; |
| 2942 | assert_eq!; |
| 2943 | |
| 2944 | |
| 2945 | |
| 2946 | |
| 2947 | assert_eq!; |
| 2948 | assert_eq!; |
| 2949 | assert_eq!; |
| 2950 | |
| 2951 | |
| 2952 | |
| 2953 | |
| 2954 | // Three of goingson's five sites tone the figure by their own means, so |
| 2955 | // tone is carried at every site that needs it and derived at none. The |
| 2956 | // same reasoning `Meter` reached, from a different direction. |
| 2957 | let streak = new.tone; |
| 2958 | assert_eq!; |
| 2959 | assert_eq!; |
| 2960 | |
| 2961 | |
| 2962 | |
| 2963 | |
| 2964 | // 0.13.0. The MNW server's stat card is a label, a value and a delta, |
| 2965 | // across four screens, and the delta is what reads as good or bad. Tone |
| 2966 | // had no consumer before this: the figure itself is an ordinary fact. |
| 2967 | let views = new |
| 2968 | .change |
| 2969 | .tone; |
| 2970 | assert_eq!; |
| 2971 | assert_eq!; |
| 2972 | |
| 2973 | // A figure with nothing to compare against says so by having no change, |
| 2974 | // rather than by carrying an empty string a renderer has to test for. |
| 2975 | assert_eq!; |
| 2976 | |
| 2977 | |
| 2978 | |
| 2979 | |
| 2980 | // "84%", "12/30", "3d". A figure is whatever the app computed, already |
| 2981 | // formatted, and that is the line between this and `Meter`: a meter is |
| 2982 | // a proportion a renderer draws, a figure is a fact it sets in type. |
| 2983 | for value in |
| 2984 | assert_eq!; |
| 2985 | |
| 2986 | |
| 2987 | |
| 2988 | |
| 2989 | |
| 2990 | // The meter carries the tone, so a part-level intent underneath would |
| 2991 | // fight it. Same answer `Tokens` needed, for the same reason. |
| 2992 | assert_eq!; |
| 2993 | |
| 2994 | |
| 2995 | |
| 2996 | |
| 2997 | // It is a control the user operates, unlike `Hidden`, and it does not |
| 2998 | // pick from a list the description carries, unlike `Select`. |
| 2999 | assert!; |
| 3000 | assert!; |
| 3001 | assert!; |
| 3002 | |
| 3003 | |
| 3004 | |
| 3005 | |
| 3006 | // The whole model: the description carries the rule, the renderer emits |
| 3007 | // its host's idiom, and `error` is what arrives back when someone |
| 3008 | // validated. Nothing here decides a value is wrong. |
| 3009 | let field = Field |
| 3010 | max_length: Some, |
| 3011 | min: Some, |
| 3012 | max: Some, |
| 3013 | required: true, |
| 3014 | ..new |
| 3015 | ; |
| 3016 | assert!; |
| 3017 | |
| 3018 | // A bound is text because it is only a number for some of the kinds |
| 3019 | // that take one. goingson has both shapes live. |
| 3020 | let when = Field |
| 3021 | min: Some, |
| 3022 | ..new |
| 3023 | ; |
| 3024 | assert_eq!; |
| 3025 | |
| 3026 | |
| 3027 | |
| 3028 | |
| 3029 | // The whole reason this is a pair. goingson's `Task::time_progress` |
| 3030 | // clamps to 100 and then carries `is_over_estimate` beside it to say |
| 3031 | // what the clamp dropped; a meter says both from one fact. |
| 3032 | let over = new; |
| 3033 | assert_eq!; |
| 3034 | assert!; |
| 3035 | |
| 3036 | let exact = new; |
| 3037 | assert_eq!; |
| 3038 | assert!; |
| 3039 | |
| 3040 | |
| 3041 | |
| 3042 | |
| 3043 | // Sayable on purpose, so it has to be answerable. A meter over an |
| 3044 | // unloaded count is what an app actually has for a frame. |
| 3045 | let none = new; |
| 3046 | assert_eq!; |
| 3047 | assert!; |
| 3048 | assert!; |
| 3049 | |
| 3050 | |
| 3051 | |
| 3052 | |
| 3053 | // Given 43 nothing can recover "3 of 7", which is why the numbers are |
| 3054 | // carried and the label names only the noun. |
| 3055 | let m = new.label; |
| 3056 | assert_eq!; |
| 3057 | assert_eq!; |
| 3058 | assert_eq!; |
| 3059 | |
| 3060 | |
| 3061 | |
| 3062 | |
| 3063 | // The same fullness means opposite things on two of goingson's bars, |
| 3064 | // and only the app knows which. |
| 3065 | let subtasks = new.tone; |
| 3066 | let estimate = new.tone; |
| 3067 | assert_eq!; |
| 3068 | assert_ne!; |
| 3069 | // Untoned by default: a bar says nothing about status until something |
| 3070 | // says so, the same way a row is not selectable until told. |
| 3071 | assert_eq!; |
| 3072 | |
| 3073 | |
| 3074 | |
| 3075 | |
| 3076 | // The one member a renderer must branch on, and since 0.19.0 the only |
| 3077 | // member there is. A stated state is not by itself a reason to stop |
| 3078 | // answering, which is the distinction `State` makes and every |
| 3079 | // hand-rolled button in the tree had to remember. |
| 3080 | assert!; |
| 3081 | assert!; |
| 3082 | |
| 3083 | |
| 3084 | |
| 3085 | |
| 3086 | // No key is the ordinary case, and the webview hosts that ignore it |
| 3087 | // are why it stayed optional. |
| 3088 | assert_eq!; |
| 3089 | let quit = new.key.tone; |
| 3090 | assert_eq!; |
| 3091 | assert_eq!; |
| 3092 | |
| 3093 | |
| 3094 | |
| 3095 | |
| 3096 | // done * 100 in u32 would wrap somewhere past 42 million. Counts that |
| 3097 | // size are not tasks, but a description layer that silently reports 3% |
| 3098 | // for a full bar is worse than one that is slow. |
| 3099 | let big = new; |
| 3100 | assert_eq!; |
| 3101 | assert!; |
| 3102 | |
| 3103 | |
| 3104 | |
| 3105 | |
| 3106 | let = Raised.edges; |
| 3107 | let = Inset.edges; |
| 3108 | assert_eq!; |
| 3109 | assert_eq!; |
| 3110 | |
| 3111 | |
| 3112 | |
| 3113 | |
| 3114 | for b in |
| 3115 | assert_eq!; |
| 3116 | |
| 3117 | |
| 3118 | |
| 3119 | |
| 3120 | |
| 3121 | // The bug this vocabulary exists to make unrepresentable. |
| 3122 | assert_eq!; |
| 3123 | assert_eq!; |
| 3124 | assert_eq!; |
| 3125 | assert_ne!; |
| 3126 | |
| 3127 | |
| 3128 | |
| 3129 | |
| 3130 | // The reason State is its own axis and not a Depth member: a disabled |
| 3131 | // button and a disabled field are both disabled and are not the same |
| 3132 | // shape, which one shared variant could not have said. |
| 3133 | assert_eq!; |
| 3134 | assert_eq!; |
| 3135 | assert!; |
| 3136 | |
| 3137 | |
| 3138 | |
| 3139 | |
| 3140 | // Kept in spirit from the version where `Focus` was the counter-example: |
| 3141 | // suppressing interaction is `Disabled`'s alone, so a member added here |
| 3142 | // later does not get to inherit it by being a state. |
| 3143 | assert!; |
| 3144 | |
| 3145 | |
| 3146 | |
| 3147 | |
| 3148 | // No new token, so this costs no `makeover` release. |
| 3149 | assert_eq!; |
| 3150 | |
| 3151 | |
| 3152 | |
| 3153 | |
| 3154 | assert_eq!; |
| 3155 | assert_eq!; |
| 3156 | |
| 3157 | |
| 3158 | |
| 3159 | |
| 3160 | // The one member carrying a fill without a bevel. A renderer that |
| 3161 | // assumes the two arrive together drops the fill silently, which is |
| 3162 | // exactly what makeover-webview did before 0.3.0. |
| 3163 | assert_eq!; |
| 3164 | assert_eq!; |
| 3165 | |
| 3166 | |
| 3167 | |
| 3168 | |
| 3169 | // Both edgeless, and only one of them needs a colour. Collapsing them |
| 3170 | // is what left an unchosen tab unsayable. |
| 3171 | assert_eq!; |
| 3172 | assert_ne!; |
| 3173 | |
| 3174 | |
| 3175 | |
| 3176 | |
| 3177 | // Authored in opposite directions: makeover derives surface-well by |
| 3178 | // inverting against the theme's content colour, while surface-sunken is |
| 3179 | // authored and may sit darker than raised. |
| 3180 | assert_ne!; |
| 3181 | assert_eq!; |
| 3182 | assert_eq!; |
| 3183 | |
| 3184 | |
| 3185 | |
| 3186 | |
| 3187 | // The gap 0.3.0 closed. Before it, only `chosen` existed and the |
| 3188 | // unchosen option fell through to Flat at every renderer. |
| 3189 | for s in |
| 3190 | assert_ne! |
| 3191 | s.chosen, |
| 3192 | s.unchosen, |
| 3193 | "{s:?} cannot tell picked from unpicked" |
| 3194 | ; |
| 3195 | |
| 3196 | |
| 3197 | |
| 3198 | |
| 3199 | |
| 3200 | // Tabs recede so the chosen one comes forward; a segment and a toggle |
| 3201 | // stand up so the chosen one is held in. That inversion is the whole |
| 3202 | // content of "picked" once colour is deferred, and it is why the three |
| 3203 | // are not one member with a flag. |
| 3204 | assert_eq!; |
| 3205 | assert_eq!; |
| 3206 | |
| 3207 | for s in |
| 3208 | assert_eq!; |
| 3209 | assert_eq!; |
| 3210 | // Held in is what pressing produces: one appearance, two reasons. |
| 3211 | assert_eq!; |
| 3212 | |
| 3213 | |
| 3214 | |
| 3215 | |
| 3216 | |
| 3217 | assert_eq!; |
| 3218 | assert_eq! |
| 3219 | Raised.pressed.bevel, |
| 3220 | Raised.bevel.map |
| 3221 | ; |
| 3222 | // Only raised regions respond to being pressed. |
| 3223 | assert_eq!; |
| 3224 | assert_eq!; |
| 3225 | // An overlay is a surface, not a control. |
| 3226 | assert_eq!; |
| 3227 | |
| 3228 | |
| 3229 | |
| 3230 | |
| 3231 | // The wave-2 rule: a surface over the page takes elevation, a surface |
| 3232 | // in the page takes a bevel. Both halves come off the one Depth, so |
| 3233 | // they cannot disagree. |
| 3234 | assert_eq!; |
| 3235 | assert_eq!; |
| 3236 | |
| 3237 | // Three depths have no bevel and they are not the same claim. Flat has |
| 3238 | // nothing to separate from, Sunken's colour is doing the separating, |
| 3239 | // and an overlay is separated by the lift. |
| 3240 | assert_ne!; |
| 3241 | assert_ne!; |
| 3242 | |
| 3243 | |
| 3244 | |
| 3245 | |
| 3246 | assert_eq!; |
| 3247 | assert_eq!; |
| 3248 | assert_eq!; |
| 3249 | assert_eq!; |
| 3250 | // No value ever leaves this crate. |
| 3251 | for t in |
| 3252 | Light.token, |
| 3253 | Dark.token, |
| 3254 | Danger.token, |
| 3255 | Neutral.token, |
| 3256 | Disabled.token, |
| 3257 | ] |
| 3258 | assert!; |
| 3259 | assert! |
| 3260 | !t.chars.next.unwrap.is_ascii_digit, |
| 3261 | "{t} is a value" |
| 3262 | ; |
| 3263 | |
| 3264 | |
| 3265 | |
| 3266 | |
| 3267 | |
| 3268 | // The one line that runs through all three apps' taxonomies. |
| 3269 | assert!; |
| 3270 | assert!; |
| 3271 | assert!; |
| 3272 | |
| 3273 | // A badge is a label, so giving it an edge would lie about it. |
| 3274 | assert_eq!; |
| 3275 | assert_eq!; |
| 3276 | |
| 3277 | // A latched chip wears the same shape a pressed one does. |
| 3278 | let chip = Chip ; |
| 3279 | assert_eq!; |
| 3280 | assert_eq!; |
| 3281 | |
| 3282 | |
| 3283 | |
| 3284 | |
| 3285 | assert!; |
| 3286 | assert!; |
| 3287 | // A toast floats above the page; a banner rests in the flow. |
| 3288 | assert_eq!; |
| 3289 | assert_eq!; |
| 3290 | |
| 3291 | |
| 3292 | |
| 3293 | |
| 3294 | // `revealed_on_hover` was asserted here until 0.13.0 retired it. It said |
| 3295 | // a row's actions stay hidden until hover, which stopped being true when |
| 3296 | // makeover-webview 0.23.0 showed them at rest, and nothing had consumed |
| 3297 | // it for a release either way. |
| 3298 | assert_eq!; |
| 3299 | assert_eq!; |
| 3300 | assert_eq!; |
| 3301 | |
| 3302 | |
| 3303 | |
| 3304 | |
| 3305 | // Each token carries its own tone, so a part-level intent underneath |
| 3306 | // would fight the thing sitting on it. Same reasoning as actions, which |
| 3307 | // is why they answer alike. |
| 3308 | assert_eq!; |
| 3309 | assert_eq!; |
| 3310 | |
| 3311 | |
| 3312 | |
| 3313 | |
| 3314 | // The pair is named once so a host with parsing to do asks here rather |
| 3315 | // than spelling it out, which is `offers_options`' reason. |
| 3316 | assert!; |
| 3317 | assert!; |
| 3318 | |
| 3319 | for kind in |
| 3320 | Text, |
| 3321 | Secret, |
| 3322 | Number, |
| 3323 | Email, |
| 3324 | Url, |
| 3325 | Tel, |
| 3326 | Textarea, |
| 3327 | Select, |
| 3328 | Radio, |
| 3329 | Checkbox, |
| 3330 | File, |
| 3331 | Hidden, |
| 3332 | ] |
| 3333 | assert!; |
| 3334 | |
| 3335 | |
| 3336 | |
| 3337 | |
| 3338 | |
| 3339 | // The formats are the whole reason the members are worth naming apart |
| 3340 | // from text, so the doc comments and the constants have to agree. A |
| 3341 | // host reading one and meeting the other is the silent failure. |
| 3342 | assert_eq!; |
| 3343 | assert!; |
| 3344 | |
| 3345 | assert_eq!; |
| 3346 | assert! |
| 3347 | DATETIME_FORMAT.starts_with, |
| 3348 | "a moment starts with the day it is on" |
| 3349 | ; |
| 3350 | // Local, and that is a property of the value rather than an omission. |
| 3351 | assert!; |
| 3352 | assert!; |
| 3353 | assert!; |
| 3354 | |
| 3355 | |
| 3356 | |
| 3357 | |
| 3358 | // Neither is a checkbox and neither is a fixed set, so both fall where |
| 3359 | // text does. Asserted because a new kind lands in three predicates and |
| 3360 | // only one of them is the interesting one. |
| 3361 | for kind in |
| 3362 | assert!; |
| 3363 | assert!; |
| 3364 | assert!; |
| 3365 | assert!; |
| 3366 | |
| 3367 | |
| 3368 | |
| 3369 | |
| 3370 | |
| 3371 | // The table half of what RowPart::intent does for rows. A cell holding |
| 3372 | // a control and a cell holding text answered alike until 0.14.0, and a |
| 3373 | // control in a cell took the cell's text colour. |
| 3374 | assert_eq!; |
| 3375 | |
| 3376 | for part in |
| 3377 | // Each for its own reason -- a token carries its tone, an action is |
| 3378 | // a control, a link takes the action colour -- and all three reach |
| 3379 | // the intent inheriting already gives. |
| 3380 | assert_eq!; |
| 3381 | |
| 3382 | |
| 3383 | |
| 3384 | |
| 3385 | |
| 3386 | for part in |
| 3387 | Value, |
| 3388 | Tokens, |
| 3389 | Actions, |
| 3390 | Link, |
| 3391 | ] |
| 3392 | let intent = part.intent; |
| 3393 | assert!; |
| 3394 | assert!; |
| 3395 | |
| 3396 | |
| 3397 | |
| 3398 | |
| 3399 | |
| 3400 | assert!; |
| 3401 | assert!; |
| 3402 | assert!; |
| 3403 | |
| 3404 | |
| 3405 | |
| 3406 | |
| 3407 | assert_eq!; |
| 3408 | assert_eq!; |
| 3409 | // The exception, and the whole folder semantic: the open tab joins its |
| 3410 | // pane rather than sinking away from it. |
| 3411 | assert_eq!; |
| 3412 | |
| 3413 | // A held-in segment is indistinguishable from a pressed raised one, |
| 3414 | // which is the economy the light model buys over a colour swap. |
| 3415 | assert_eq!; |
| 3416 | |
| 3417 | // A toggle stands alone; the other two are built out of parts that |
| 3418 | // touch. |
| 3419 | assert!; |
| 3420 | assert!; |
| 3421 | assert!; |
| 3422 | |
| 3423 | |
| 3424 | |
| 3425 | |
| 3426 | // Every renderer divides by this. A caller passing a backwards or empty |
| 3427 | // span is a bug, but it is not a bug worth a panic three renderers deep. |
| 3428 | assert_eq!; |
| 3429 | assert_eq!; |
| 3430 | assert_eq!; |
| 3431 | |
| 3432 | |
| 3433 | |
| 3434 | |
| 3435 | // 22:00 to 02:00. The alternative was carrying a date, which drags a |
| 3436 | // timezone into the vocabulary for the sake of one night shift. |
| 3437 | let overnight = new; |
| 3438 | assert_eq!; |
| 3439 | assert!; |
| 3440 | assert!; |
| 3441 | |
| 3442 | |
| 3443 | |
| 3444 | |
| 3445 | // The reason Placement carries no `conflicts` flag: the times already |
| 3446 | // say it, and a second source for one fact is how a stale conflict |
| 3447 | // badge outlives the conflict. |
| 3448 | let morning = new; // 09:00-10:00 |
| 3449 | let overlapping = new; // 09:30-10:30 |
| 3450 | let after = new; // 10:00-11:00 |
| 3451 | |
| 3452 | assert!; |
| 3453 | assert!; |
| 3454 | // Touching end to end is not overlapping: `to` is exclusive, so a |
| 3455 | // 10:00 start does not collide with a 10:00 end. |
| 3456 | assert!; |
| 3457 | assert!; |
| 3458 | |
| 3459 | |
| 3460 | |
| 3461 | |
| 3462 | assert_eq!; |
| 3463 | assert_eq!; |
| 3464 | |
| 3465 | |
| 3466 | |
| 3467 | |
| 3468 | let day = DAY; |
| 3469 | assert!; |
| 3470 | assert!; |
| 3471 | // Clamped rather than off the end: an event running past the span's |
| 3472 | // close draws at the edge, which beats panicking or drawing nowhere. |
| 3473 | assert!; |
| 3474 | |
| 3475 | |
| 3476 | |
| 3477 | |
| 3478 | assert_eq!; |
| 3479 | assert_eq!; |
| 3480 | // A span that does not divide evenly keeps a slot for its tail. |
| 3481 | assert_eq!; |
| 3482 | // slot: 0 is a caller bug that reads as one slot, not a panic. |
| 3483 | let degenerate = Track |
| 3484 | span: DAY, |
| 3485 | slot: 0, |
| 3486 | tick: 60, |
| 3487 | ; |
| 3488 | assert_eq!; |
| 3489 | |
| 3490 | |
| 3491 | |
| 3492 | |
| 3493 | // The guard on the thing the withdrawn refusal was right about. If a |
| 3494 | // pixel measure, a scroll offset or a colour ever lands on Track, the |
| 3495 | // member has stopped being a fact about the data and the timeline |
| 3496 | // really has become a component library wearing a description's name. |
| 3497 | let day = DAY; |
| 3498 | assert_eq!; |
| 3499 | assert_eq!; |
| 3500 | assert_eq!; |
| 3501 | // Three fields. Adding a fourth should have to come here and say why. |
| 3502 | assert_eq!; |
| 3503 | |
| 3504 | |
| 3505 | |
| 3506 | |
| 3507 | assert_eq!; |
| 3508 | assert_eq!; |
| 3509 | for r in |
| 3510 | Band, |
| 3511 | Sidebar, |
| 3512 | Split, |
| 3513 | TabGroup, |
| 3514 | ] |
| 3515 | assert_eq!; |
| 3516 | |
| 3517 | |
| 3518 | |
| 3519 | |
| 3520 | |
| 3521 | // The escape hatch is one member and stays one member. If a second |
| 3522 | // undescribed region ever appears, the description has started |
| 3523 | // conceding rather than deferring. |
| 3524 | for r in |
| 3525 | Band, |
| 3526 | Sidebar, |
| 3527 | Pane, |
| 3528 | Split, |
| 3529 | TabGroup, |
| 3530 | Modal, |
| 3531 | // A widget is described, and that is the whole of what separates it |
| 3532 | // from a bespoke here. Both carry a name this crate never reads; |
| 3533 | // only one of them has contents under it that a renderer which does |
| 3534 | // not know the name can still walk. |
| 3535 | Widget , |
| 3536 | ] |
| 3537 | assert!; |
| 3538 | |
| 3539 | assert!; |
| 3540 | |
| 3541 | |
| 3542 | |
| 3543 | |
| 3544 | // The distinction a renderer with no graphics protocol runs on: draw |
| 3545 | // the words, or draw nothing. Standing in for a decorative rule with |
| 3546 | // the word "decoration" is worse than leaving the space empty. |
| 3547 | assert!; |
| 3548 | assert!; |
| 3549 | |
| 3550 | |
| 3551 | |
| 3552 | |
| 3553 | // A caption is content everybody reads; alt text stands in for the |
| 3554 | // picture. A screenshot with a caption still needs alt text. |
| 3555 | let shot = new.caption; |
| 3556 | assert_eq!; |
| 3557 | assert!; |
| 3558 | assert_ne!; |
| 3559 | |
| 3560 | |
| 3561 | |
| 3562 | |
| 3563 | // The whole point: a renderer reserves from the ratio, so the space is |
| 3564 | // right at any width. A fixed height would only be right at one. |
| 3565 | let shot = new.intrinsic; |
| 3566 | let e = shot.intrinsic.expect; |
| 3567 | assert_eq!; |
| 3568 | assert!; |
| 3569 | |
| 3570 | |
| 3571 | |
| 3572 | |
| 3573 | // `None` is honest: a creator upload whose size was never recorded does |
| 3574 | // not know it. A renderer must not invent one. |
| 3575 | assert_eq!; |
| 3576 | assert_eq!; |
| 3577 | assert_eq!; |
| 3578 | |
| 3579 | |
| 3580 | |
| 3581 | |
| 3582 | // Eager is the safe default and lazy is the opt-in, because deferring |
| 3583 | // something already on screen saves nothing and moves its shift later. |
| 3584 | assert_eq!; |
| 3585 | assert_eq!; |
| 3586 | assert_eq!; |
| 3587 | |
| 3588 | |
| 3589 | |
| 3590 | |
| 3591 | // The default is the one that shows the whole picture at its own shape, |
| 3592 | // so a renderer ignoring Fit entirely is still right about the common |
| 3593 | // case. The shipped MNW carousel sets no object-fit at all, which is |
| 3594 | // this. |
| 3595 | assert_eq!; |
| 3596 | assert_eq!; |
| 3597 | assert_eq!; |
| 3598 | |
| 3599 | |
| 3600 | |
| 3601 | |
| 3602 | // Stronger than the bespoke case: a widget is drawn by whichever |
| 3603 | // renderer recognises the name, so a depth chosen here would be this |
| 3604 | // crate deciding a carousel is raised on every host. |
| 3605 | assert_eq!; |
| 3606 | assert_eq!; |
| 3607 | |
| 3608 | |
| 3609 | |
| 3610 | |
| 3611 | // A renderer dispatching on a name wants the string, not the member. |
| 3612 | // Writing that `matches!` at each renderer is how the two drift apart. |
| 3613 | assert_eq!; |
| 3614 | assert_eq! |
| 3615 | Bespoke .name, |
| 3616 | Some |
| 3617 | ; |
| 3618 | |
| 3619 | for r in |
| 3620 | Band, |
| 3621 | Sidebar, |
| 3622 | Pane, |
| 3623 | Split, |
| 3624 | TabGroup, |
| 3625 | Modal, |
| 3626 | ] |
| 3627 | assert_eq!; |
| 3628 | |
| 3629 | |
| 3630 | |
| 3631 | |
| 3632 | |
| 3633 | // The app owns the contents, not the placement. An app that wants its |
| 3634 | // timeline in a well frames it in a Pane. |
| 3635 | assert_eq!; |
| 3636 | assert_eq!; |
| 3637 | |
| 3638 | |
| 3639 | |
| 3640 | |
| 3641 | // The argument the member exists for: goingson's day-plan has to be |
| 3642 | // routable, or the description covers only the boring screens and the |
| 3643 | // interesting four need a second path beside the router. |
| 3644 | let day_plan = |
| 3645 | Band, |
| 3646 | Bespoke , |
| 3647 | Sidebar, |
| 3648 | ]; |
| 3649 | assert_eq!; |
| 3650 | assert_eq!; |
| 3651 | |
| 3652 | |
| 3653 | |
| 3654 | |
| 3655 | let secret = new; |
| 3656 | assert!; |
| 3657 | assert!; |
| 3658 | |
| 3659 | assert!; |
| 3660 | // Nothing else is confidential, or the marker means nothing. |
| 3661 | for k in |
| 3662 | Text, |
| 3663 | Number, |
| 3664 | Textarea, |
| 3665 | Select, |
| 3666 | Checkbox, |
| 3667 | Hidden, |
| 3668 | ] |
| 3669 | assert!; |
| 3670 | |
| 3671 | |
| 3672 | // Only a checkbox carries its own label. |
| 3673 | assert!; |
| 3674 | assert!; |
| 3675 | |
| 3676 | |
| 3677 | |
| 3678 | |
| 3679 | let text = new; |
| 3680 | assert!; |
| 3681 | assert_eq!; |
| 3682 | |
| 3683 | let sizes = ; |
| 3684 | let select = select; |
| 3685 | assert_eq!; |
| 3686 | assert_eq!; |
| 3687 | |
| 3688 | |
| 3689 | |
| 3690 | |
| 3691 | // The whole reason it is two strings. `plain` is the case where they |
| 3692 | // coincide, and it is a shorthand rather than the general shape. |
| 3693 | let plain = plain; |
| 3694 | assert_eq!; |
| 3695 | |
| 3696 | let spelled = Choice |
| 3697 | value: "7", |
| 3698 | label: "One week", |
| 3699 | ; |
| 3700 | assert_ne!; |
| 3701 | |
| 3702 | |
| 3703 | |
| 3704 | |
| 3705 | // Both offer a fixed set and both read `options`, so the two |
| 3706 | // constructors differ in exactly one thing. That one thing is the |
| 3707 | // point: a renderer decides whether the alternatives are readable |
| 3708 | // without opening anything, and it can only decide that if the |
| 3709 | // description said which question was asked. |
| 3710 | let styles = |
| 3711 | Choice |
| 3712 | value: "copy", |
| 3713 | label: "Copy samples in", |
| 3714 | , |
| 3715 | Choice |
| 3716 | value: "reference", |
| 3717 | label: "Reference in place", |
| 3718 | , |
| 3719 | ]; |
| 3720 | let radio = radio; |
| 3721 | let select = select; |
| 3722 | |
| 3723 | assert_eq!; |
| 3724 | assert_ne!; |
| 3725 | assert_eq!; |
| 3726 | assert_eq! |
| 3727 | Field |
| 3728 | kind: select.kind, |
| 3729 | ..radio |
| 3730 | , |
| 3731 | select |
| 3732 | ; |
| 3733 | |
| 3734 | |
| 3735 | |
| 3736 | |
| 3737 | // The renderers branch on this rather than on a list of their own, so |
| 3738 | // a kind added without a decision here renders its options nowhere. |
| 3739 | assert!; |
| 3740 | assert!; |
| 3741 | for kind in |
| 3742 | Text, |
| 3743 | Secret, |
| 3744 | Number, |
| 3745 | Email, |
| 3746 | Url, |
| 3747 | Tel, |
| 3748 | Textarea, |
| 3749 | Checkbox, |
| 3750 | Hidden, |
| 3751 | ] |
| 3752 | assert!; |
| 3753 | |
| 3754 | |
| 3755 | |
| 3756 | |
| 3757 | |
| 3758 | // The near-miss: each option is labelled beside its own button, so a |
| 3759 | // renderer could plausibly read the group as self-labelling and drop |
| 3760 | // the question. Checkbox is the only kind that does that. |
| 3761 | assert!; |
| 3762 | assert!; |
| 3763 | |
| 3764 | |
| 3765 | |
| 3766 | |
| 3767 | // An app whose option list has not loaded has exactly this. Making it |
| 3768 | // unrepresentable would push the state somewhere less visible, and a |
| 3769 | // renderer drawing an empty select reports it on screen. |
| 3770 | let loading = select; |
| 3771 | assert!; |
| 3772 | |
| 3773 | |
| 3774 | |
| 3775 | |
| 3776 | // The line 0.8.0 drew. Placeholder and options are properties of what |
| 3777 | // is being asked; the current value is what came back, and no field |
| 3778 | // here holds one. |
| 3779 | let f = Field |
| 3780 | placeholder: Some, |
| 3781 | ..new |
| 3782 | ; |
| 3783 | assert_eq!; |
| 3784 | // A placeholder is not a label, and having one does not excuse the |
| 3785 | // field from carrying the other. |
| 3786 | assert_eq!; |
| 3787 | |
| 3788 | |
| 3789 | |
| 3790 | |
| 3791 | let mut f = new; |
| 3792 | assert!; |
| 3793 | f.error = Some; |
| 3794 | assert!; |
| 3795 | |
| 3796 | |
| 3797 | |
| 3798 | |
| 3799 | let cols = |
| 3800 | Column |
| 3801 | width: Fill, |
| 3802 | priority: Essential, |
| 3803 | ..new |
| 3804 | , |
| 3805 | Column |
| 3806 | width: Fixed, |
| 3807 | priority: Secondary, |
| 3808 | ..new |
| 3809 | , |
| 3810 | Column |
| 3811 | width: Fixed, |
| 3812 | priority: Optional, |
| 3813 | ..new |
| 3814 | , |
| 3815 | ]; |
| 3816 | |
| 3817 | // Widest: everything survives. |
| 3818 | assert_eq! |
| 3819 | cols.iter |
| 3820 | .filter |
| 3821 | .count, |
| 3822 | 3 |
| 3823 | ; |
| 3824 | // Narrower: the optional column goes first. |
| 3825 | let kept: = cols |
| 3826 | .iter |
| 3827 | .filter |
| 3828 | .map |
| 3829 | .collect; |
| 3830 | assert_eq!; |
| 3831 | // Narrowest: only what identifies the row. |
| 3832 | let kept: = cols |
| 3833 | .iter |
| 3834 | .filter |
| 3835 | .map |
| 3836 | .collect; |
| 3837 | assert_eq!; |
| 3838 | |
| 3839 | |
| 3840 | |
| 3841 | |
| 3842 | // The bug the ordinal form has and this form cannot: goingson hides |
| 3843 | // `nth-child(n+5)` against a seven-column table, so a column inserted |
| 3844 | // anywhere to the left silently hides a different one. |
| 3845 | let before = |
| 3846 | new, |
| 3847 | Column |
| 3848 | width: Fixed, |
| 3849 | priority: Optional, |
| 3850 | ..new |
| 3851 | , |
| 3852 | ]; |
| 3853 | let after = |
| 3854 | new, |
| 3855 | new, // inserted |
| 3856 | Column |
| 3857 | width: Fixed, |
| 3858 | priority: Optional, |
| 3859 | ..new |
| 3860 | , |
| 3861 | ]; |
| 3862 | |
| 3863 | |
| 3864 | cols.iter |
| 3865 | .filter |
| 3866 | .map |
| 3867 | .collect |
| 3868 | |
| 3869 | assert_eq!; |
| 3870 | assert_eq!; |
| 3871 | |
| 3872 | |
| 3873 | |
| 3874 | |
| 3875 | // goingson uses the tab group inside the content region rather than |
| 3876 | // instead of one, so it is not a third arrangement. |
| 3877 | let go = list_detail; |
| 3878 | let plain = list_detail; |
| 3879 | assert_ne!; |
| 3880 | assert_ne!; |
| 3881 | |
| 3882 | |
| 3883 | |
| 3884 | |
| 3885 | // The point of the member: a terminal reading columns and a webview |
| 3886 | // reading a grid honour one fact, so two hosts showing one screen agree |
| 3887 | // about its proportions. |
| 3888 | assert_eq!; |
| 3889 | assert_eq!; |
| 3890 | assert_eq! |
| 3891 | SIDEBAR.of, |
| 3892 | 24, |
| 3893 | "quasi-tui's 24 columns, said as a quarter" |
| 3894 | ; |
| 3895 | |
| 3896 | |
| 3897 | |
| 3898 | |
| 3899 | // A region the description named should be visible. A zero-width one |
| 3900 | // reads on screen as a region that vanished, which is the hardest kind |
| 3901 | // of bug to find from what is drawn. |
| 3902 | assert_eq!; |
| 3903 | assert_eq!; |
| 3904 | |
| 3905 | |
| 3906 | |
| 3907 | |
| 3908 | assert_eq!; |
| 3909 | assert_eq!; |
| 3910 | |
| 3911 | |
| 3912 | |
| 3913 | |
| 3914 | // How much a sidebar takes and how much a list side takes are different |
| 3915 | // questions, and this enum is the only thing that knows which is being |
| 3916 | // asked. |
| 3917 | assert_eq!; |
| 3918 | assert_eq!; |
| 3919 | |
| 3920 | let narrow = sidebar_content.with_share; |
| 3921 | assert_eq!; |
| 3922 | assert!; |
| 3923 | |
| 3924 | |
| 3925 | |
| 3926 | |
| 3927 | // The default is meaningful: a screen nobody said anything about uses |
| 3928 | // the window it was given. |
| 3929 | assert_eq!; |
| 3930 | assert_eq!; |
| 3931 | |
| 3932 | |
| 3933 | |
| 3934 | |
| 3935 | // Two members and no third. If a skeleton ever appears in this enum, |
| 3936 | // the deferral rule has been broken. |
| 3937 | assert_ne!; |
| 3938 | |
| 3939 | |
| 3940 |