edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits
| 1 | //! Segmented choice: every answer a short setting takes, on the setting's own |
| 2 | //! row, the one in force lit, a click on any other picking it outright. The |
| 3 | //! settings page's answer to its "press to cycle" rows (UX audit D-1): a cycle |
| 4 | //! button shows one value and hides the rest behind a press, so a person |
| 5 | //! cannot know what a row offers without stepping all the way round it. Five |
| 6 | //! answers or fewer fit on one row as chips; a longer list is a dropdown |
| 7 | //! ([`crate::Pick`]) -- still one click away, and the row's caret says so. |
| 8 | //! |
| 9 | //! Keyboard: the settings page's own arrow branch |
| 10 | //! ([`crate::ui::settings_stance::settings_arrow`]) moves a focus between the |
| 11 | //! choice rows (`↑`/`↓`) and steps the focused row's value (`←`/`→`) -- the |
| 12 | //! radio group's convention, where an arrow both moves and picks, so there |
| 13 | //! is no second "confirm" stroke to learn. The focused row wears DESIGN |
| 14 | //! §4.10's 1px `ink2` top rule, so where the keyboard is looking is visible |
| 15 | //! before a key is pressed. |
| 16 | //! |
| 17 | //! A file of its own rather than a widget in `ui/widgets.rs`: another lane |
| 18 | //! changed that file at the same time, and this helper has no sibling there. |
| 19 | |
| 20 | use cratehitmap; |
| 21 | use crate; |
| 22 | use crate::*; |
| 23 | use SharedString; |
| 24 | |
| 25 | /// One chip of a segmented row: its word, and whether it is the value in |
| 26 | /// force. |
| 27 | |
| 28 | pub |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | /// The chips of a row from its labels and the index in force: exactly one is |
| 34 | /// lit, or none when `current` names no row (a setting with nothing behind |
| 35 | /// it yet, like the tonemap before a project opens). |
| 36 | pub |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | /// The index an arrow steps to from `current` in a row of `len`: the next |
| 51 | /// one, wrapping at either end, so the stroke never dead-ends on the last |
| 52 | /// chip -- the cycle buttons this replaces wrapped, and a hand used to that |
| 53 | /// keeps it. |
| 54 | pub |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | /// Where `↑`/`↓` lands among `len` rows: the next row, wrapping; from no |
| 65 | /// focus, the first row (`↓`) or the last (`↑`). `None` for a tab with no |
| 66 | /// choice rows, where there is nothing for a focus to sit on. |
| 67 | pub |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | /// A chip's side padding, and the gap between two chips. |
| 79 | pub const CHIP_PAD: f32 = 8.; |
| 80 | pub const CHIP_GAP: f32 = 2.; |
| 81 | |
| 82 | /// A chip's width as the page measures it before it is drawn -- the mono |
| 83 | /// badge glyph's advance per character, generous, plus the padding. For the |
| 84 | /// fit guard in the tests, never the layout: gpui measures the real thing. |
| 85 | |
| 86 | pub |
| 87 | |
| 88 | |
| 89 | |
| 90 | /// The width a whole segmented row of `labels` asks for, chips and gaps. |
| 91 | |
| 92 | pub |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | /// The segmented row: one chip per entry, each a hit area of its own |
| 101 | /// (`{id}-{i}`, so the harness can press any answer, not only the next one). |
| 102 | /// The chip in force wears the raised plate and `ink1`; the others are `ink3` |
| 103 | /// and light on hover. Disabled, every chip is `ink4` and takes no click -- |
| 104 | /// the row stays in the tree saying what it offers, which is the point. |
| 105 | /// `hint` is the row's own sentence, on every chip's hover line. `pick` is |
| 106 | /// called with the chip's index; it is `Copy` so each chip can carry its own |
| 107 | /// listener. |
| 108 | pub |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 |