edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits
| 1 | //! REDESIGN §1.5 / §6 -- the component kit every redesigned region is built |
| 2 | //! from: one set of hover / pressed / focus / disabled rules (§1.5), three |
| 3 | //! button styles, toggle, segmented control, switch, scrub-number field, |
| 4 | //! section head and keycap. |
| 5 | //! |
| 6 | //! These sit beside the legacy helpers in `ui::widgets` (`control`, `tip_*`, |
| 7 | //! `focus_ring`), which stay for the existing call sites; later phases move |
| 8 | //! regions over to this module and then retire the legacy ones. |
| 9 | //! |
| 10 | //! Rules every component here keeps: |
| 11 | //! * **No layout shift.** Sizes are fixed by the style; hover, press, focus |
| 12 | //! and "on" change colour only (the one border a component has is always |
| 13 | //! there, only its colour changes). |
| 14 | //! * **Colours come from [`theme::tokens`]**, never a literal. |
| 15 | //! * **State is overridable.** Each builder takes an optional [`Look`] that |
| 16 | //! forces a visual state, which is how the component gallery paints every |
| 17 | //! state at once and how a keyboard-focused control (whose handle the |
| 18 | //! caller owns) is drawn. |
| 19 | //! * Builders return a plain `Stateful<Div>`: chain `.on_click(..)`, |
| 20 | //! `.tooltip(..)`, drag handlers on the result. A disabled component draws |
| 21 | //! dimmed with a not-allowed cursor and should be given no handler. |
| 22 | |
| 23 | use crateredesign as r; |
| 24 | use crate; |
| 25 | use crate; |
| 26 | use crate; |
| 27 | use crate::*; |
| 28 | use ; |
| 29 | use RefCell; |
| 30 | use Rc; |
| 31 | use ; |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | /// A forced visual state (see the module doc); `None` means live (pointer-driven). |
| 42 | /// `Focus` keeps the rest fill and adds the accent ring; the others pin the |
| 43 | /// fill hover or press would give. |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | /// A control's three fills: at rest, under the pointer, pressed. |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | /// The keyboard-focus ring (§1.5): the control's own 1px border turns `accent`. |
| 94 | /// Every component here carries a 1px border that is transparent at rest, so |
| 95 | /// focus never moves a neighbour. (A spread shadow was tried first: gpui |
| 96 | /// paints it *under* the element, so a transparent ghost button filled solid |
| 97 | /// accent; and the spec's 2px/1px-offset needs the parent surface colour.) |
| 98 | /// Needs the element to hold a gpui focus handle to show live; `Look::Focus` |
| 99 | /// forces it. |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | /// Whether the last input was the keyboard (Tab in a dialog). Set on Tab, cleared by any |
| 106 | /// mouse press, read when a focused control paints its ring. |
| 107 | static KBD_RING: AtomicBool = new; |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | thread_local! |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | /// The open [`choice_list`] of the last frame, for the arrow keys: which one, how many rows, |
| 119 | /// the highlighted row, and the pick handler. |
| 120 | type PickFn = ; |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | thread_local! |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | /// The tallest a [`choice_list`] gets before it scrolls: a long list (a font list, say) stays on |
| 138 | /// the window and its rows are reached with the wheel or the arrow keys. |
| 139 | pub const LIST_MAX_H: f32 = 320.; |
| 140 | |
| 141 | /// How tall a [`choice_list`] of `rows` rows is: its rows and padding, capped at [`LIST_MAX_H`]. |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | /// Whether the list of `rows` rows for the dropdown field `field` opens above the field, because |
| 147 | /// there is no room for it below on the window. Only the `top` or `bottom` offset of the list |
| 148 | /// changes: the list stays 2px clear of the field, below it or above it. |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | /// The scroll handle of the list `id`. |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | /// Start a frame: no handle is used yet, and no list is known to be open until one draws. |
| 159 | /// Call once before any [`tab_scope`]. |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | /// Up, Down and Enter for the [`choice_list`] that is open: Up and Down move its highlighted |
| 171 | /// row (wrapping), Enter picks it. `true` when the key was the list's (the caller repaints). |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | /// Runs `build`, giving every kit control made inside it (`states`) a tab stop from `pool`, in |
| 197 | /// build order. Controls built outside a scope stay out of the Tab order, so a dialog's Tab |
| 198 | /// never walks the window behind it. |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | /// A row-like control that is not a kit button (a settings row, a chip, a swatch): a tab stop |
| 207 | /// inside a [`tab_scope`], lit with an accent wash while the keyboard is on it. |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | /// Applies the §1.5 state table to an element (which must carry a 1px border, |
| 229 | /// see [`focus_ring_accent`]): the fill for each state, the focus border, the |
| 230 | /// pointer, and the disabled dimming. `forced` pins a state instead of |
| 231 | /// waiting for the pointer. |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | /// The three button styles (§1.5). Exactly these. |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | /// Control heights (§1.2): 24 small, 28 default, 32 toolbar / primary, 36 hero. |
| 265 | |
| 266 | |
| 267 | |
| 268 | |
| 269 | |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 | |
| 277 | |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | |
| 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | |
| 293 | |
| 294 | |
| 295 | |
| 296 | |
| 297 | |
| 298 | |
| 299 | |
| 300 | |
| 301 | |
| 302 | |
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | /// A button, icon button or toggle, depending on what it is given: |
| 309 | /// a label, an icon, both, and (for the ghost style) `.on(true)`. |
| 310 | /// |
| 311 | /// ```ignore |
| 312 | /// Button::new("export").label("Export").style(ButtonStyle::Primary).build() |
| 313 | /// .on_click(|_, _, cx| ..) |
| 314 | /// Button::new("snap").icon(Icon::Magnet).label("Snap").size(ButtonSize::Large).on(snap).build() |
| 315 | /// Button::new("play").icon(Icon::Play).size(ButtonSize::Large).build() // icon-only: square |
| 316 | /// ``` |
| 317 | |
| 318 | |
| 319 | |
| 320 | |
| 321 | |
| 322 | |
| 323 | |
| 324 | |
| 325 | |
| 326 | |
| 327 | |
| 328 | |
| 329 | |
| 330 | |
| 331 | |
| 332 | |
| 333 | |
| 334 | |
| 335 | |
| 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | |
| 341 | |
| 342 | |
| 343 | |
| 344 | |
| 345 | |
| 346 | |
| 347 | |
| 348 | |
| 349 | |
| 350 | |
| 351 | |
| 352 | |
| 353 | |
| 354 | |
| 355 | |
| 356 | |
| 357 | |
| 358 | |
| 359 | |
| 360 | |
| 361 | |
| 362 | |
| 363 | |
| 364 | |
| 365 | |
| 366 | |
| 367 | |
| 368 | |
| 369 | |
| 370 | |
| 371 | |
| 372 | |
| 373 | |
| 374 | |
| 375 | |
| 376 | |
| 377 | |
| 378 | |
| 379 | |
| 380 | |
| 381 | |
| 382 | |
| 383 | |
| 384 | |
| 385 | |
| 386 | |
| 387 | |
| 388 | |
| 389 | |
| 390 | |
| 391 | |
| 392 | |
| 393 | |
| 394 | |
| 395 | |
| 396 | |
| 397 | |
| 398 | |
| 399 | |
| 400 | |
| 401 | |
| 402 | |
| 403 | |
| 404 | |
| 405 | |
| 406 | |
| 407 | |
| 408 | |
| 409 | |
| 410 | |
| 411 | |
| 412 | |
| 413 | |
| 414 | |
| 415 | |
| 416 | |
| 417 | |
| 418 | |
| 419 | |
| 420 | |
| 421 | |
| 422 | |
| 423 | |
| 424 | |
| 425 | |
| 426 | |
| 427 | |
| 428 | |
| 429 | |
| 430 | |
| 431 | |
| 432 | |
| 433 | |
| 434 | |
| 435 | |
| 436 | |
| 437 | |
| 438 | |
| 439 | |
| 440 | |
| 441 | |
| 442 | |
| 443 | |
| 444 | |
| 445 | |
| 446 | |
| 447 | /// One entry of a [`segmented`] control. |
| 448 | |
| 449 | |
| 450 | |
| 451 | |
| 452 | |
| 453 | |
| 454 | |
| 455 | |
| 456 | |
| 457 | |
| 458 | |
| 459 | |
| 460 | |
| 461 | |
| 462 | |
| 463 | |
| 464 | |
| 465 | |
| 466 | |
| 467 | |
| 468 | /// The segmented control (§1.5): an `e2` track, the selected pill `e3`. |
| 469 | /// 28px tall, every pill the same weight so selecting never reflows the row. |
| 470 | /// `on_select` gets the index of the pill clicked. `forced` pins one pill's |
| 471 | /// state (gallery). This replaces every "Off On" text row. |
| 472 | |
| 473 | |
| 474 | |
| 475 | |
| 476 | |
| 477 | |
| 478 | |
| 479 | |
| 480 | |
| 481 | |
| 482 | |
| 483 | /// [`segmented`] that fills the width it is given with every pill the same |
| 484 | /// width (`flex_1`), for rows of a few short options ("Left Centre Right") |
| 485 | /// where a ragged track looks unfinished. Put it in a parent with a width. |
| 486 | |
| 487 | |
| 488 | |
| 489 | |
| 490 | |
| 491 | |
| 492 | |
| 493 | |
| 494 | |
| 495 | |
| 496 | |
| 497 | /// [`segmented`] for more options than fit one row of a narrow panel: the |
| 498 | /// track takes the parent's width and the pills wrap onto further lines, so a |
| 499 | /// label is never clipped. The track grows by a pill row per wrap (so give it |
| 500 | /// room, or reserve the height of the wrapped case). |
| 501 | |
| 502 | |
| 503 | |
| 504 | |
| 505 | |
| 506 | |
| 507 | |
| 508 | |
| 509 | |
| 510 | |
| 511 | |
| 512 | /// How a segmented track sizes itself. |
| 513 | |
| 514 | |
| 515 | |
| 516 | |
| 517 | |
| 518 | |
| 519 | |
| 520 | |
| 521 | |
| 522 | |
| 523 | |
| 524 | |
| 525 | |
| 526 | |
| 527 | |
| 528 | |
| 529 | |
| 530 | |
| 531 | |
| 532 | |
| 533 | |
| 534 | |
| 535 | |
| 536 | |
| 537 | |
| 538 | |
| 539 | |
| 540 | |
| 541 | |
| 542 | |
| 543 | |
| 544 | |
| 545 | |
| 546 | |
| 547 | |
| 548 | |
| 549 | |
| 550 | |
| 551 | |
| 552 | |
| 553 | |
| 554 | |
| 555 | |
| 556 | |
| 557 | |
| 558 | |
| 559 | |
| 560 | |
| 561 | |
| 562 | |
| 563 | |
| 564 | |
| 565 | |
| 566 | |
| 567 | |
| 568 | |
| 569 | |
| 570 | |
| 571 | |
| 572 | |
| 573 | |
| 574 | |
| 575 | |
| 576 | |
| 577 | |
| 578 | |
| 579 | |
| 580 | |
| 581 | |
| 582 | |
| 583 | |
| 584 | |
| 585 | |
| 586 | |
| 587 | |
| 588 | |
| 589 | |
| 590 | |
| 591 | |
| 592 | |
| 593 | |
| 594 | |
| 595 | |
| 596 | |
| 597 | /// The switch (§1.5): a 32x18 track and a 12px knob. On is `accent_fill` with |
| 598 | /// a dark knob; off is `e3` with an `ink2` knob. The knob is absolutely |
| 599 | /// placed, so the control's box is the same either way. |
| 600 | |
| 601 | |
| 602 | |
| 603 | |
| 604 | |
| 605 | |
| 606 | |
| 607 | |
| 608 | |
| 609 | |
| 610 | |
| 611 | |
| 612 | |
| 613 | |
| 614 | |
| 615 | |
| 616 | |
| 617 | |
| 618 | |
| 619 | |
| 620 | |
| 621 | |
| 622 | |
| 623 | |
| 624 | |
| 625 | |
| 626 | |
| 627 | |
| 628 | |
| 629 | |
| 630 | |
| 631 | /// Which state a [`scrub_field`] is in. |
| 632 | |
| 633 | |
| 634 | |
| 635 | |
| 636 | |
| 637 | |
| 638 | |
| 639 | /// The scrub-number field (§6): 24px, `e2`; hover `e3` with a `col-resize` |
| 640 | /// cursor; typing shows a 1px `accent` border and a caret. The value is |
| 641 | /// `caption` with tabular figures, the unit `ink3`. The 1px border is always |
| 642 | /// there (transparent unless typing), so focusing never shifts the box. |
| 643 | /// Dragging and typing are the caller's: attach `on_drag` / `on_click` to the |
| 644 | /// result. |
| 645 | |
| 646 | |
| 647 | |
| 648 | |
| 649 | |
| 650 | |
| 651 | |
| 652 | |
| 653 | |
| 654 | |
| 655 | |
| 656 | |
| 657 | |
| 658 | |
| 659 | |
| 660 | |
| 661 | |
| 662 | |
| 663 | |
| 664 | |
| 665 | |
| 666 | |
| 667 | |
| 668 | |
| 669 | |
| 670 | |
| 671 | |
| 672 | |
| 673 | |
| 674 | |
| 675 | |
| 676 | |
| 677 | |
| 678 | |
| 679 | |
| 680 | |
| 681 | |
| 682 | |
| 683 | |
| 684 | |
| 685 | |
| 686 | |
| 687 | |
| 688 | /// An inspector section head (§1.1 `section`): 12px Inter 600, sentence case, |
| 689 | /// `ink2`, in a 24px row; `trailing` (a reset button, a chevron) sits at the right. |
| 690 | |
| 691 | |
| 692 | |
| 693 | |
| 694 | |
| 695 | |
| 696 | |
| 697 | |
| 698 | |
| 699 | |
| 700 | |
| 701 | |
| 702 | |
| 703 | /// A key shown in a tooltip, menu or sheet (§5 rule 1: nowhere else): `e4` |
| 704 | /// plate, `line_hi` border, `caption` text. |
| 705 | |
| 706 | |
| 707 | |
| 708 | |
| 709 | |
| 710 | |
| 711 | |
| 712 | |
| 713 | |
| 714 | |
| 715 | |
| 716 | |
| 717 | |
| 718 | |
| 719 | |
| 720 | |
| 721 | |
| 722 | |
| 723 | |
| 724 | /// The one popup plate (§1.6): `e3`, 1px `line_hi` border, radius 6 (8 for |
| 725 | /// sheets and the palette), soft shadow. Menus, dropdowns, tooltips and toasts |
| 726 | /// all start from this. |
| 727 | |
| 728 | |
| 729 | |
| 730 | |
| 731 | |
| 732 | |
| 733 | |
| 734 | |
| 735 | |
| 736 | |
| 737 | |
| 738 | |
| 739 | |
| 740 | |
| 741 | |
| 742 | // --------------------------------------------------------------------------- |
| 743 | // Card components: what the property cards, the sheets and the dialogs are |
| 744 | // built from. Each takes its handler as an argument and attaches it only when |
| 745 | // the control is live, so a disabled one cannot be driven by a stray click. |
| 746 | // --------------------------------------------------------------------------- |
| 747 | |
| 748 | /// A switch row: the label (and, under it, an optional one-line description in |
| 749 | /// `ink3`) on the left, the [`switch`] on the right, the whole row one click |
| 750 | /// target. `off_why` disables it: the row dims, the cursor says not-allowed, a |
| 751 | /// hover tooltip gives the reason, and `on_toggle` is never attached, so the |
| 752 | /// row ignores input. |
| 753 | /// |
| 754 | /// ```ignore |
| 755 | /// switch_row("loop", "Loop playback", Some("Start again at the end".into()), on, None, |
| 756 | /// move |_, cx| entity.update(cx, |p, cx| p.toggle_loop(cx))) |
| 757 | /// ``` |
| 758 | |
| 759 | |
| 760 | |
| 761 | |
| 762 | |
| 763 | |
| 764 | |
| 765 | |
| 766 | |
| 767 | |
| 768 | |
| 769 | |
| 770 | |
| 771 | |
| 772 | |
| 773 | |
| 774 | |
| 775 | |
| 776 | |
| 777 | |
| 778 | |
| 779 | |
| 780 | |
| 781 | |
| 782 | |
| 783 | |
| 784 | |
| 785 | |
| 786 | |
| 787 | |
| 788 | |
| 789 | |
| 790 | |
| 791 | |
| 792 | |
| 793 | |
| 794 | |
| 795 | |
| 796 | |
| 797 | |
| 798 | |
| 799 | |
| 800 | |
| 801 | |
| 802 | |
| 803 | |
| 804 | /// The reset slot: a 24px square that is *always* in the layout. It holds the |
| 805 | /// ghost reset icon (tooltip "Reset to default") while `show`, and is empty |
| 806 | /// otherwise, so a value that changes never nudges its neighbours. The click is |
| 807 | /// attached only while shown. |
| 808 | |
| 809 | |
| 810 | |
| 811 | |
| 812 | |
| 813 | |
| 814 | |
| 815 | |
| 816 | |
| 817 | |
| 818 | |
| 819 | |
| 820 | |
| 821 | |
| 822 | |
| 823 | |
| 824 | /// A value pill: a fixed-width `e2` box with the value right-aligned in tabular |
| 825 | /// `caption` (`ink1` once changed from the default, `ink2` at the default) and |
| 826 | /// the [`reset_slot`] beside it. Width and slot never change, so editing a |
| 827 | /// value moves nothing. |
| 828 | |
| 829 | |
| 830 | |
| 831 | |
| 832 | |
| 833 | |
| 834 | |
| 835 | |
| 836 | |
| 837 | |
| 838 | |
| 839 | |
| 840 | |
| 841 | |
| 842 | |
| 843 | |
| 844 | |
| 845 | |
| 846 | |
| 847 | |
| 848 | |
| 849 | |
| 850 | |
| 851 | |
| 852 | |
| 853 | |
| 854 | |
| 855 | |
| 856 | |
| 857 | |
| 858 | |
| 859 | |
| 860 | |
| 861 | |
| 862 | |
| 863 | /// A number being typed into a [`number_field`]: the buffer, with the first |
| 864 | /// keystroke replacing the old text (it opens fully selected). Wire it like |
| 865 | /// this: a click (or double-click) on the field makes |
| 866 | /// `NumberEdit::begin(&shown)`; each key goes to [`NumberEdit::key`]; on |
| 867 | /// `Commit` call [`NumberEdit::commit`] and write the value, on `Cancel` just |
| 868 | /// drop the edit. Dragging the field is [`scrub_value`]. |
| 869 | |
| 870 | |
| 871 | |
| 872 | |
| 873 | |
| 874 | |
| 875 | |
| 876 | |
| 877 | |
| 878 | |
| 879 | |
| 880 | |
| 881 | |
| 882 | |
| 883 | |
| 884 | |
| 885 | |
| 886 | |
| 887 | |
| 888 | |
| 889 | |
| 890 | |
| 891 | |
| 892 | |
| 893 | |
| 894 | |
| 895 | |
| 896 | |
| 897 | |
| 898 | |
| 899 | |
| 900 | |
| 901 | |
| 902 | |
| 903 | |
| 904 | |
| 905 | |
| 906 | |
| 907 | |
| 908 | /// The value after dragging a [`number_field`] `dx` pixels from where the drag |
| 909 | /// began at `start`: `per_px` units a pixel (a tenth of that with `fine`, which |
| 910 | /// callers wire to Shift), clamped to `min..=max`. |
| 911 | |
| 912 | |
| 913 | |
| 914 | |
| 915 | |
| 916 | |
| 917 | /// The number field (§6): a [`scrub_field`] that also shows what is being |
| 918 | /// typed. `editing` is the [`NumberEdit`] buffer while the user types (1px |
| 919 | /// `accent` border, caret), `None` at rest, where the field drags to scrub |
| 920 | /// (`col-resize` cursor). Compose with a [`reset_slot`] to its right for the |
| 921 | /// reset-to-default affordance. Drag, click and key wiring are the caller's. |
| 922 | |
| 923 | |
| 924 | |
| 925 | |
| 926 | |
| 927 | |
| 928 | |
| 929 | |
| 930 | |
| 931 | |
| 932 | |
| 933 | |
| 934 | |
| 935 | |
| 936 | /// `#RRGGBB` for an `0xRRGGBB` colour. |
| 937 | |
| 938 | |
| 939 | |
| 940 | |
| 941 | /// The colour a typed `#RRGGBB` (or `RRGGBB`, or `#RGB`) names. |
| 942 | |
| 943 | |
| 944 | |
| 945 | |
| 946 | |
| 947 | |
| 948 | |
| 949 | |
| 950 | |
| 951 | |
| 952 | |
| 953 | |
| 954 | |
| 955 | |
| 956 | /// The swatch row: round swatches, the current colour wearing a ring. A |
| 957 | /// current colour that is not in `colours` (a custom one) is shown as an extra |
| 958 | /// swatch at the end, ringed, so the row always says what is in force. After |
| 959 | /// the swatches, the `#RRGGBB` field (`hex_editing` is the typed text while the |
| 960 | /// field is being edited); a click on it calls `on_hex`. The user's own colour |
| 961 | /// is used exactly: nothing here rounds it to a swatch. |
| 962 | |
| 963 | |
| 964 | |
| 965 | |
| 966 | |
| 967 | |
| 968 | |
| 969 | |
| 970 | |
| 971 | |
| 972 | |
| 973 | |
| 974 | |
| 975 | |
| 976 | |
| 977 | |
| 978 | |
| 979 | |
| 980 | |
| 981 | |
| 982 | |
| 983 | |
| 984 | |
| 985 | |
| 986 | |
| 987 | |
| 988 | |
| 989 | |
| 990 | |
| 991 | |
| 992 | |
| 993 | |
| 994 | |
| 995 | |
| 996 | |
| 997 | |
| 998 | |
| 999 | |
| 1000 | |
| 1001 | |
| 1002 | |
| 1003 | |
| 1004 | |
| 1005 | |
| 1006 | |
| 1007 | |
| 1008 | |
| 1009 | |
| 1010 | |
| 1011 | |
| 1012 | |
| 1013 | |
| 1014 | |
| 1015 | |
| 1016 | |
| 1017 | |
| 1018 | |
| 1019 | |
| 1020 | |
| 1021 | |
| 1022 | |
| 1023 | |
| 1024 | |
| 1025 | |
| 1026 | |
| 1027 | |
| 1028 | /// The closed half of a card dropdown: an `e2` row control, the current value |
| 1029 | /// on the left, a chevron on the right, 28px tall. It records its bounds under |
| 1030 | /// `id` ([`crate::ui::anchor`]) so the list it opens hangs from it: on click |
| 1031 | /// call `Player::picker_at_control(Pick::..)` for an enumerated setting, or |
| 1032 | /// show a [`choice_list`] at [`crate::ui::anchor::hang`]. A blank value reads |
| 1033 | /// `Custom` (the setting matches none of the listed choices), never an empty box. |
| 1034 | |
| 1035 | |
| 1036 | |
| 1037 | |
| 1038 | |
| 1039 | |
| 1040 | |
| 1041 | |
| 1042 | |
| 1043 | |
| 1044 | |
| 1045 | |
| 1046 | |
| 1047 | |
| 1048 | |
| 1049 | |
| 1050 | |
| 1051 | |
| 1052 | |
| 1053 | |
| 1054 | |
| 1055 | |
| 1056 | |
| 1057 | |
| 1058 | |
| 1059 | |
| 1060 | |
| 1061 | |
| 1062 | |
| 1063 | |
| 1064 | /// The open half of a card dropdown: a [`plate`] of rows, the one in force |
| 1065 | /// marked with a check (no focus ring: that appears only on keyboard |
| 1066 | /// navigation). Position it absolutely at [`crate::ui::anchor::hang`] of the |
| 1067 | /// field. `on_pick` gets the row's index. |
| 1068 | |
| 1069 | |
| 1070 | |
| 1071 | |
| 1072 | |
| 1073 | |
| 1074 | |
| 1075 | |
| 1076 | |
| 1077 | |
| 1078 | /// Moves the highlight of the open list `id` to row `ix` and brings that row into view: for a list |
| 1079 | /// whose rows just changed (a search narrowed them). |
| 1080 | |
| 1081 | |
| 1082 | |
| 1083 | |
| 1084 | |
| 1085 | |
| 1086 | |
| 1087 | |
| 1088 | |
| 1089 | |
| 1090 | /// [`choice_list`] whose row `i` is drawn in the font family `faces[i]` when it is `Some`, and in |
| 1091 | /// the UI font when it is `None` or `faces` is short. Up, Down and Enter work it as they do any |
| 1092 | /// list ([`list_nav`]). A list taller than [`LIST_MAX_H`] scrolls. |
| 1093 | |
| 1094 | |
| 1095 | |
| 1096 | |
| 1097 | |
| 1098 | |
| 1099 | |
| 1100 | |
| 1101 | |
| 1102 | |
| 1103 | |
| 1104 | |
| 1105 | |
| 1106 | |
| 1107 | |
| 1108 | |
| 1109 | |
| 1110 | |
| 1111 | |
| 1112 | |
| 1113 | |
| 1114 | |
| 1115 | |
| 1116 | |
| 1117 | |
| 1118 | |
| 1119 | |
| 1120 | |
| 1121 | |
| 1122 | |
| 1123 | |
| 1124 | |
| 1125 | |
| 1126 | |
| 1127 | |
| 1128 | |
| 1129 | |
| 1130 | |
| 1131 | |
| 1132 | |
| 1133 | |
| 1134 | |
| 1135 | |
| 1136 | |
| 1137 | |
| 1138 | |
| 1139 | |
| 1140 | |
| 1141 | |
| 1142 | |
| 1143 | |
| 1144 | |
| 1145 | |
| 1146 | |
| 1147 | |
| 1148 | |
| 1149 | |
| 1150 | |
| 1151 | |
| 1152 | |
| 1153 | |
| 1154 | |
| 1155 | |
| 1156 | /// One row of a [`plate`] list: the [`choice_list`] row on its own, for a plate that holds |
| 1157 | /// more than one list. A check marks the one in force. |
| 1158 | |
| 1159 | |
| 1160 | |
| 1161 | |
| 1162 | |
| 1163 | |
| 1164 | |
| 1165 | |
| 1166 | |
| 1167 | |
| 1168 | |
| 1169 | |
| 1170 | |
| 1171 | |
| 1172 | |
| 1173 | |
| 1174 | |
| 1175 | |
| 1176 | |
| 1177 | |
| 1178 | |
| 1179 | |
| 1180 | |
| 1181 | |
| 1182 | |
| 1183 | /// A ghost icon button with a tooltip, for row actions (move up, move down, |
| 1184 | /// remove). While `why` is `Some` it is disabled (dimmed, not-allowed, no |
| 1185 | /// handler) and the tooltip gives the reason instead of the name. |
| 1186 | |
| 1187 | |
| 1188 | |
| 1189 | |
| 1190 | |
| 1191 | |
| 1192 | |
| 1193 | |
| 1194 | |
| 1195 | |
| 1196 | |
| 1197 | |
| 1198 | |
| 1199 | |
| 1200 | |
| 1201 | |
| 1202 | |
| 1203 | |
| 1204 | |
| 1205 | |
| 1206 | /// A chord drawn as keycaps: `"Ctrl+Shift+R"` is three [`keycap`]s with a |
| 1207 | /// small gap. A trailing `+` is the plus key (`"Ctrl++"`), and a bare `+` or |
| 1208 | /// `-` is its own key. `" or "` separates alternatives (`"Ctrl+Y or Ctrl+Shift+Z"`), |
| 1209 | /// each drawn as its own run with a plain "or" between. For sheets, the |
| 1210 | /// palette's hint column and tooltips only (§5 rule 1). |
| 1211 | |
| 1212 | |
| 1213 | |
| 1214 | |
| 1215 | |
| 1216 | |
| 1217 | |
| 1218 | |
| 1219 | |
| 1220 | |
| 1221 | |
| 1222 | /// The width [`keycaps`] takes for `chord`, from the same split: each cap's |
| 1223 | /// text plus its padding and border (never narrower than the cap's minimum), a |
| 1224 | /// 3px gap between caps, and the "or" word between alternatives. A tooltip sizes |
| 1225 | /// its plate from this, so a long chord is not clipped. |
| 1226 | |
| 1227 | |
| 1228 | |
| 1229 | |
| 1230 | |
| 1231 | |
| 1232 | |
| 1233 | |
| 1234 | |
| 1235 | |
| 1236 | |
| 1237 | |
| 1238 | |
| 1239 | |
| 1240 | /// One alternative's keys: `"Ctrl+Shift+R"` is three, `"Ctrl++"` is "Ctrl" and |
| 1241 | /// "+", a bare `"+"` or `"-"` is itself. |
| 1242 | |
| 1243 | |
| 1244 | |
| 1245 | |
| 1246 | |
| 1247 | |
| 1248 | |
| 1249 | |
| 1250 | |
| 1251 | |
| 1252 | |
| 1253 | |
| 1254 | |
| 1255 | |
| 1256 | |
| 1257 | |
| 1258 | |
| 1259 | |
| 1260 | |
| 1261 | |
| 1262 | |
| 1263 | |
| 1264 | |
| 1265 | |
| 1266 | |
| 1267 | |
| 1268 | // --------------------------------------------------------------------------- |
| 1269 | // The dialog shell: every modal sheet (New project, Save version, Versions, |
| 1270 | // Collect media, About, unsaved changes, Relink, Shortcuts) is built from this. |
| 1271 | // --------------------------------------------------------------------------- |
| 1272 | |
| 1273 | /// The dialog layer: a subtle scrim over the window *below the menu bar* (the bar stays live |
| 1274 | /// and unshaded) that centres its child in the picture region (`bottom_inset` is the height of |
| 1275 | /// the timeline under it, which the dialog never covers). A press on the scrim is the caller's |
| 1276 | /// to handle (`.on_mouse_down(..)`); the dialog itself stops it. |
| 1277 | |
| 1278 | |
| 1279 | |
| 1280 | |
| 1281 | |
| 1282 | |
| 1283 | |
| 1284 | |
| 1285 | |
| 1286 | |
| 1287 | |
| 1288 | |
| 1289 | |
| 1290 | |
| 1291 | |
| 1292 | |
| 1293 | /// The dialog plate: [`plate`]`(8)`, `w` wide, 20px padding, children stacked |
| 1294 | /// 12px apart, height hugging its content, and the close X at its top right |
| 1295 | /// (it asks the window to cancel whatever dialog is up, the same as Esc). |
| 1296 | /// Put `dialog_title`, a body and [`dialog_actions`] in it. |
| 1297 | |
| 1298 | |
| 1299 | |
| 1300 | |
| 1301 | |
| 1302 | |
| 1303 | |
| 1304 | |
| 1305 | |
| 1306 | |
| 1307 | |
| 1308 | |
| 1309 | |
| 1310 | |
| 1311 | |
| 1312 | |
| 1313 | |
| 1314 | |
| 1315 | |
| 1316 | |
| 1317 | |
| 1318 | |
| 1319 | |
| 1320 | |
| 1321 | |
| 1322 | |
| 1323 | |
| 1324 | |
| 1325 | |
| 1326 | |
| 1327 | |
| 1328 | |
| 1329 | |
| 1330 | /// A dialog's title: one size for every dialog (`title`, `ink1`), clear of the close X. |
| 1331 | |
| 1332 | |
| 1333 | |
| 1334 | |
| 1335 | /// A dialog's body line: `body`, `ink2`, wrapping. |
| 1336 | |
| 1337 | |
| 1338 | |
| 1339 | |
| 1340 | /// The button row at a dialog's foot: right-aligned, 8px between buttons. |
| 1341 | |
| 1342 | |
| 1343 | |
| 1344 | |
| 1345 | |
| 1346 | |
| 1347 | |
| 1348 | |
| 1349 | |
| 1350 | |
| 1351 | |
| 1352 | |
| 1353 | |
| 1354 | |
| 1355 | |
| 1356 | |
| 1357 | |
| 1358 | |
| 1359 | |
| 1360 | |
| 1361 | |
| 1362 | |
| 1363 | |
| 1364 | |
| 1365 | |
| 1366 | |
| 1367 | |
| 1368 | |
| 1369 | |
| 1370 | |
| 1371 | |
| 1372 | |
| 1373 | |
| 1374 | |
| 1375 | |
| 1376 | |
| 1377 | |
| 1378 | |
| 1379 |