edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiBfbc29d1Tahinli2 months ago972 commits
| 1 | //! The small elements every region is built out of. |
| 2 | |
| 3 | use crate::*; |
| 4 | |
| 5 | /// `ClickEvent::modifiers()` answers the mouse-*up* modifiers (gpui-0.2.2 |
| 6 | /// `interactive.rs`), so releasing ctrl before the button lands undoes a |
| 7 | /// ctrl-held toggle decided on mouse-down. This reads the *press* modifiers |
| 8 | /// instead -- the ones a ctrl-click decision (multi-pick, no collapse) was |
| 9 | /// actually made under. |
| 10 | pub |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | /// As [`waveform`], but in a caller-picked ink rather than the fixed |
| 18 | /// secondary foreground -- the darkroom bench's own audio clips draw their |
| 19 | /// envelope in the source's ink (DESIGN §5), which the legacy timeline never |
| 20 | /// needed a colour for. |
| 21 | pub |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | /// An audio clip's fade, drawn as a translucent wedge over its box: silent |
| 57 | /// (full shade) at the clip's own edge, clear by the fade's far side -- |
| 58 | /// [`is_in`] mirrors it for the tail's ramp-down. The same `canvas` + |
| 59 | /// `PathBuilder` idiom [`waveform`] draws its envelope with, filled with the |
| 60 | /// same wash the in/out range already paints the bed with |
| 61 | /// (`ACCENT_WASH`, timeline.rs), so a fade reads as one more overlay on this |
| 62 | /// bed rather than a shape borrowed from somewhere else. |
| 63 | pub |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | /// A video clip's dissolve into its neighbour, drawn as a small X astride the |
| 98 | /// join -- the box it is given is the last [`Clip::transition_out`] frames of |
| 99 | /// the clip's own width, so the mark sits right at the edge it dissolves |
| 100 | /// through. Two strokes rather than [`fade_wedge`]'s fill: a dissolve is not |
| 101 | /// a ramp to or from silence, it is two clips overlapping, and an X reads as |
| 102 | /// a splice the way a wedge reads as a fade. |
| 103 | pub |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | /// The hover line every control in the room wears (the user, 2026-09-09: |
| 126 | /// "each and every button gets hover over information" -- nobody could name |
| 127 | /// the band's own glyphs). One shape, built from the same pair the hitmap |
| 128 | /// already names the control by: `<name> · <chord>`, DESIGN §4's "every |
| 129 | /// command wears its chord" and §8's no-prose rule -- never a sentence. A |
| 130 | /// control the current state refuses says *why* in the chord's place: naming |
| 131 | /// a stroke that will not fire is the lie §4 forbids. |
| 132 | pub |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | /// [`tip_line`] in the shape gpui's `.tooltip` takes. Every shared control |
| 144 | /// constructor attaches this rather than building its own plate, which is |
| 145 | /// what keeps the next control from shipping without a hover line. |
| 146 | pub |
| 147 | |
| 148 | |
| 149 | |
| 150 | + use<> |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | /// [`tip_hover`] for a control drawn *on* a card or a menu, where an |
| 156 | /// ordinary [`Tip`] stands aside (`OVERLAID`) and would show nothing. |
| 157 | pub |
| 158 | |
| 159 | |
| 160 | |
| 161 | + use<> |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | /// [`tip_hover`] for a control that dispatches an action: the name and the |
| 167 | /// stroke are read live off the keymap and the enable state, so a rebind or |
| 168 | /// a refusal can never leave a stale plate under the pointer. |
| 169 | pub |
| 170 | |
| 171 | |
| 172 | + use<> |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | /// A toolbar button: its glyph, its name, and its key on hover. `id` only buys |
| 179 | /// `on_click` and the tooltip -- it is still not focusable, so the root's own |
| 180 | /// key listener keeps working after a press, and the click lands on mouse-up |
| 181 | /// inside the button (a press that slides off does nothing). |
| 182 | /// |
| 183 | /// A button that would do nothing says so: dimmed, no pointer, no listener. |
| 184 | pub |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | /// The monitoring level as something to drag: 4 px of bar to look at and the |
| 248 | /// whole control's height to hit (WCAG 2.5.8), the split the speed bar and the |
| 249 | /// colour sliders both make. Only the level -- mute is the button beside it, so |
| 250 | /// a muted slider still shows what unmuting comes back to, drawn dim. |
| 251 | /// |
| 252 | /// Whether a card or a menu is drawn over the window, as the hover labels see |
| 253 | /// it: written once a frame by [`Player::render`], read by every [`Tip`] before |
| 254 | /// it paints. |
| 255 | /// |
| 256 | /// A tooltip already on screen when an overlay opens *stays* on screen in gpui: |
| 257 | /// occluding the surface under it does not take it back, because the check that |
| 258 | /// keeps it visible works off the element's absolute bounds and knows nothing |
| 259 | /// about what was painted over it (`div.rs::handle_tooltip_mouse_move`, its own |
| 260 | /// TODO). So the tip is what has to stand aside -- here, once, for every hover |
| 261 | /// label in this window, rather than at fifteen call sites of which the |
| 262 | /// sixteenth would be forgotten. |
| 263 | pub static OVERLAID: AtomicBool = new; |
| 264 | |
| 265 | /// Whether a tip is cleared to paint: an ordinary tip stands aside whenever |
| 266 | /// `OVERLAID` is set (a card/menu is up over the underlying UI it belongs |
| 267 | /// to), but a tip *anchored on the overlay itself* -- the `?` glyph on a |
| 268 | /// card's own head, say -- was never the case `OVERLAID` meant to catch, so |
| 269 | /// it paints regardless. One predicate, so [`Tip`] and [`OverlayTip`] can't |
| 270 | /// drift apart on what "overlaid" is supposed to mean. |
| 271 | pub |
| 272 | |
| 273 | |
| 274 | |
| 275 | /// DESIGN §4: "Notices, menus, chips, cues, and tooltips are all the same |
| 276 | /// plate" -- canvas-on-panel, 2px radius, the room's own type |
| 277 | /// (`ui::type_scale`), not a bordered box in an ad hoc size. |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | |
| 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | |
| 293 | |
| 294 | /// A tooltip is a view in gpui and nothing smaller, so this is the smallest one |
| 295 | /// that carries a line of text. It paints outside the window's element tree and |
| 296 | /// therefore owns its colours. |
| 297 | pub SharedString); |
| 298 | |
| 299 | |
| 300 | |
| 301 | |
| 302 | |
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 | |
| 314 | |
| 315 | /// A tip anchored on the overlay itself -- a card's own `?` glyph, drawn on |
| 316 | /// its own card head. `OVERLAID` exists to hide a [`Tip`] on the UI *under* |
| 317 | /// a card while the card sits over it; a tip painted on the card is not |
| 318 | /// that case, so it is exempt (`tip_may_paint(true)` is always `true`). |
| 319 | /// Everything else about it is [`Tip`]'s own plate. |
| 320 | pub SharedString); |
| 321 | |
| 322 | |
| 323 | |
| 324 | |
| 325 | |
| 326 | |
| 327 | |
| 328 | /// A number being typed into a row that has no text field of its own: the |
| 329 | /// digits so far, the range and digit cap that row enforces, and once a |
| 330 | /// commit has been refused, why. Text-field semantics on a card that has no |
| 331 | /// text field -- typing, backspace, arrows that step, enter that commits and |
| 332 | /// escape that gives up -- held as state and driven by the root's key |
| 333 | /// handler, since nothing in these rows takes gpui focus. Shared by the |
| 334 | /// export card's custom bitrate field and the transition duration row |
| 335 | /// (DEBT #111) -- one implementation, each caller its own range and unit. |
| 336 | |
| 337 | pub |
| 338 | |
| 339 | |
| 340 | |
| 341 | |
| 342 | |
| 343 | |
| 344 | |
| 345 | |
| 346 | |
| 347 | |
| 348 | |
| 349 | |
| 350 | |
| 351 | |
| 352 | |
| 353 | |
| 354 | |
| 355 | |
| 356 | |
| 357 | |
| 358 | |
| 359 | |
| 360 | |
| 361 | |
| 362 | |
| 363 | |
| 364 | |
| 365 | |
| 366 | |
| 367 | |
| 368 | |
| 369 | |
| 370 | |
| 371 | |
| 372 | |
| 373 | |
| 374 | |
| 375 | |
| 376 | |
| 377 | |
| 378 | |
| 379 | |
| 380 | |
| 381 | |
| 382 | |
| 383 | |
| 384 | |
| 385 | |
| 386 | |
| 387 | |
| 388 | |
| 389 | |
| 390 | |
| 391 | |
| 392 | |
| 393 | |
| 394 | |
| 395 | |
| 396 | |
| 397 | |
| 398 | |
| 399 | |
| 400 | |
| 401 | |
| 402 | |
| 403 | |
| 404 | |
| 405 | |
| 406 | |
| 407 | |
| 408 | |
| 409 | |
| 410 | |
| 411 | |
| 412 | |
| 413 | |
| 414 | |
| 415 | |
| 416 | |
| 417 | |
| 418 | |
| 419 | |
| 420 | |
| 421 | |
| 422 | |
| 423 | |
| 424 | |
| 425 | |
| 426 | |
| 427 | |
| 428 | |
| 429 | |
| 430 | |
| 431 | |
| 432 | |
| 433 | |
| 434 | |
| 435 | |
| 436 | |
| 437 | |
| 438 | |
| 439 | |
| 440 | |
| 441 | |
| 442 | |
| 443 | |
| 444 | |
| 445 | |
| 446 | |
| 447 | |
| 448 | |
| 449 | |
| 450 | |
| 451 | |
| 452 | |
| 453 | |
| 454 | |
| 455 | |
| 456 | |
| 457 | |
| 458 | |
| 459 | |
| 460 | |
| 461 | |
| 462 | |
| 463 | |
| 464 | |
| 465 | |
| 466 | |
| 467 | |
| 468 | |
| 469 | |
| 470 | |
| 471 | |
| 472 | |
| 473 | /// How much text the colour field will hold: `rgba(255, 255, 255, 255)` with |
| 474 | /// room to spare. Every legal colour is far inside it; the cap is there so a |
| 475 | /// held key cannot grow the buffer without bound. |
| 476 | const COLOR_EDIT_CHARS: usize = 32; |
| 477 | |
| 478 | /// A colour being typed into a row that has no text field of its own: the |
| 479 | /// free-text sibling of [`NumberEdit`], for the same reason it exists -- these |
| 480 | /// rows take no gpui focus, so the text is held as state and driven by the |
| 481 | /// root's key handler. One caller, the Clip tab's colour field |
| 482 | /// ([`Player::edit_viz_hex`]): typing, backspace, enter that commits and |
| 483 | /// escape that gives up, and a refusal in words when what is there is not a |
| 484 | /// colour. |
| 485 | |
| 486 | pub |
| 487 | |
| 488 | |
| 489 | |
| 490 | |
| 491 | |
| 492 | |
| 493 | |
| 494 | |
| 495 | |
| 496 | |
| 497 | |
| 498 | |
| 499 | |
| 500 | |
| 501 | |
| 502 | |
| 503 | |
| 504 | |
| 505 | |
| 506 | |
| 507 | |
| 508 | |
| 509 | |
| 510 | |
| 511 | |
| 512 | |
| 513 | |
| 514 | |
| 515 | |
| 516 | |
| 517 | |
| 518 | |
| 519 | |
| 520 | |
| 521 | |
| 522 | |
| 523 | |
| 524 | |
| 525 | |
| 526 | |
| 527 | |
| 528 | |
| 529 | |
| 530 | |
| 531 | |
| 532 | |
| 533 | |
| 534 | |
| 535 | |
| 536 | |
| 537 | |
| 538 | |
| 539 | |
| 540 | |
| 541 | |
| 542 | |
| 543 | |
| 544 | |
| 545 | |
| 546 | |
| 547 | |
| 548 | |
| 549 | |
| 550 | |
| 551 | |
| 552 | |
| 553 | |
| 554 | |
| 555 | /// What a window with no file open shows: DESIGN §8 wants a noun, not a |
| 556 | /// sentence -- both ways in (window drop target, Import in the media list) |
| 557 | /// are taught by their own geography, not by this label. |
| 558 | pub |
| 559 | |
| 560 | |
| 561 | |
| 562 | |
| 563 | |
| 564 | |
| 565 | |
| 566 |