A second palette, named button groups, and one live accent
Browse files at this commit5a36eae01c1b7f1385cccb7dbc563ac7af1da472Parent: 0e5864c- feat
- a second palette, named button groups, and one live accent
5 changed files +233 -88
- crates/app/Cargo.toml +5 -0
- crates/app/src/ui/library.rs +9 -1
- crates/app/src/ui/theme.rs +183 -85
- crates/app/src/ui/toolbar.rs +3 -0
- crates/app/src/ui/widgets.rs +33 -2
crates/app/Cargo.tomlmodified+5 -0
| @@ -7,6 +7,11 @@ edition.workspace = true | ||
| 7 | 7 | name = "edith" |
| 8 | 8 | path = "src/main.rs" |
| 9 | 9 | |
| 10 | +[features] | |
| 11 | +# The warm palette instead of the default cool one: same role names, different | |
| 12 | +# numbers (`ui/theme.rs`). `cargo run -p edith --features warm`. | |
| 13 | +warm = [] | |
| 14 | + | |
| 10 | 15 | [dependencies] |
| 11 | 16 | engine = { path = "../engine" } |
| 12 | 17 | gpui = "0.2.2" |
crates/app/src/ui/library.rsmodified+9 -1
| @@ -279,7 +279,15 @@ impl Player { | ||
| 279 | 279 | // there, whatever tab is open and however narrow the |
| 280 | 280 | // window is. |
| 281 | 281 | width - 16., |
| 282 | - BG_RAISED, | |
| 282 | + // Filled with the accent while there is nothing to work | |
| 283 | + // on, because with an empty library this *is* the | |
| 284 | + // primary action -- and Export, which wears the accent | |
| 285 | + // the rest of the time, is dimmed until something is | |
| 286 | + // imported. One live accent in the window either way. | |
| 287 | + match rows.is_empty() { | |
| 288 | + true => ACCENT_PRIMARY, | |
| 289 | + false => BG_RAISED, | |
| 290 | + }, | |
| 283 | 291 | None, |
| 284 | 292 | "Import", |
| 285 | 293 | "adds a file to this list — or drop one on the window".to_string(), |
crates/app/src/ui/theme.rsmodified+183 -85
| @@ -6,62 +6,192 @@ | ||
| 6 | 6 | //! *role*, never the shade -- `bg/panel`, not "the dark grey" -- so the palette |
| 7 | 7 | //! can be swapped whole without touching a single element. |
| 8 | 8 | //! |
| 9 | -//! Family B: near-black ground, cool neutral chrome, one cyan accent, with the | |
| 10 | -//! clip bodies carrying the cross-NLE kind convention (video blue, audio green, | |
| 11 | -//! image teal, text purple) instead of four greys that differ by a hair. | |
| 9 | +//! Which is what the two modules below are for. Both families carry the same | |
| 10 | +//! role names, so the switch between them is one `use` and no call site knows | |
| 11 | +//! it happened -- and a role missing from either is a compile error rather than | |
| 12 | +//! a region that quietly kept the old colour. | |
| 13 | +//! | |
| 14 | +//! * `cool` (default) -- near-black ground, cool neutral chrome, one cyan accent. | |
| 15 | +//! * `warm` (`--features warm`) -- a deep neutral warmed towards brown so no | |
| 16 | +//! surface reads as office grey, with one coral accent. | |
| 17 | +//! | |
| 18 | +//! Both take the clip bodies from the cross-NLE kind convention (video blue, | |
| 19 | +//! audio green, image teal, text purple) instead of four greys that differ by a | |
| 20 | +//! hair, and both are held to the same measured floors: the contrast guards in | |
| 21 | +//! `main.rs` run against whichever one is compiled. | |
| 22 | +//! | |
| 23 | +//! ponytail: a compile switch, because every token is a `const` and a runtime | |
| 24 | +//! palette means a lookup at every paint. Ceiling: the day the palette has to | |
| 25 | +//! change without a restart, these two modules become two `struct Palette` | |
| 26 | +//! values and the consts become fields on the one the window holds. | |
| 12 | 27 | |
| 13 | 28 | use engine::project::LaneKind; |
| 14 | 29 | |
| 15 | -// -- surfaces ----------------------------------------------------------------- | |
| 16 | -/// The app's base, and the bed a picture is letterboxed against: darker than | |
| 17 | -/// every panel, so the picture is what the eye lands on. | |
| 18 | -pub const BG_CANVAS: u32 = 0x0b0d10; | |
| 19 | -/// The library, the inspector, the toolbar: the chrome the work sits between. | |
| 20 | -pub const BG_PANEL: u32 = 0x151a21; | |
| 21 | -/// Buttons, menu bodies, cards -- one plane up from the panel. Flat: the | |
| 22 | -/// separation is colour, never a shadow. | |
| 23 | -pub const BG_RAISED: u32 = 0x212936; | |
| 24 | -/// The lane bed, darker than the panel so a clip reads as an object on it. | |
| 25 | -pub const BG_TIMELINE: u32 = 0x0e1218; | |
| 26 | -/// One step lighter than whatever it sits on: the pointer's answer that this is | |
| 27 | -/// clickable. | |
| 28 | -pub const BG_HOVER: u32 = 0x2f3a4a; | |
| 29 | -/// The same answer for the things that stand on the panel rather than on a | |
| 30 | -/// button. | |
| 31 | -pub const BG_HOVER_DIM: u32 = 0x1d2531; | |
| 32 | -/// A picked row, a picked clip: the accent at surface brightness, so a | |
| 33 | -/// selection is tinted rather than lit up. | |
| 34 | -pub const BG_SELECTED: u32 = 0x0d4b5c; | |
| 35 | -/// What a card is floated over when it is genuinely modal (the export, the | |
| 36 | -/// actions list). Inspector sections never draw one -- they occlude nothing. | |
| 37 | -pub const SCRIM: u32 = 0x0b0d10cc; | |
| 38 | - | |
| 39 | -// -- strokes ------------------------------------------------------------------ | |
| 40 | -pub const STROKE_DIVIDER: u32 = 0x2a3442; | |
| 41 | -/// The keyboard's own ring, distinct from selection on purpose: focus is where | |
| 42 | -/// the next stroke lands, selection is what an edit acts on. | |
| 43 | -pub const STROKE_FOCUS: u32 = 0xffd166; | |
| 44 | -pub const STROKE_SELECTED: u32 = 0x22d3ee; | |
| 45 | - | |
| 46 | -// -- text --------------------------------------------------------------------- | |
| 47 | -pub const FG_PRIMARY: u32 = 0xe9eff7; | |
| 48 | -/// Shortcuts, dismissal hints, detail lines. Past 4.5:1 on every surface above. | |
| 49 | -pub const FG_SECONDARY: u32 = 0xa7b6c9; | |
| 50 | -pub const FG_DISABLED: u32 = 0x6c7a8b; | |
| 51 | - | |
| 52 | -// -- interaction -------------------------------------------------------------- | |
| 53 | -pub const ACCENT_PRIMARY: u32 = 0x22d3ee; | |
| 54 | -/// Not the accent: the playhead crosses every clip colour there is and has to | |
| 55 | -/// stay the one line that is none of them. | |
| 56 | -pub const ACCENT_PLAYHEAD: u32 = 0xff9db0; | |
| 57 | -/// The accent as a translucent wash, for the marks drawn over a clip body. | |
| 58 | -pub const ACCENT_WASH: u32 = 0x22d3eeaa; | |
| 59 | - | |
| 60 | -// -- clip kinds (cross-NLE convention) ---------------------------------------- | |
| 61 | -pub const CLIP_VIDEO: u32 = 0x2b5fa8; | |
| 62 | -pub const CLIP_AUDIO: u32 = 0x276b43; | |
| 63 | -pub const CLIP_IMAGE: u32 = 0x1a6a6a; | |
| 64 | -pub const CLIP_TEXT: u32 = 0x6b46c1; | |
| 30 | +#[cfg(not(feature = "warm"))] | |
| 31 | +pub use cool::*; | |
| 32 | +#[cfg(feature = "warm")] | |
| 33 | +pub use warm::*; | |
| 34 | + | |
| 35 | +/// Family B: near-black ground, cool neutral chrome, one cyan accent. | |
| 36 | +pub mod cool { | |
| 37 | + // -- surfaces --------------------------------------------------------------- | |
| 38 | + /// The app's base, and the bed a picture is letterboxed against: darker than | |
| 39 | + /// every panel, so the picture is what the eye lands on. | |
| 40 | + pub const BG_CANVAS: u32 = 0x0b0d10; | |
| 41 | + /// The library, the inspector, the toolbar: the chrome the work sits between. | |
| 42 | + pub const BG_PANEL: u32 = 0x151a21; | |
| 43 | + /// Buttons, menu bodies, cards -- one plane up from the panel. Flat: the | |
| 44 | + /// separation is colour, never a shadow. | |
| 45 | + pub const BG_RAISED: u32 = 0x212936; | |
| 46 | + /// The lane bed, darker than the panel so a clip reads as an object on it. | |
| 47 | + pub const BG_TIMELINE: u32 = 0x0e1218; | |
| 48 | + /// One step lighter than whatever it sits on: the pointer's answer that this | |
| 49 | + /// is clickable. | |
| 50 | + pub const BG_HOVER: u32 = 0x2f3a4a; | |
| 51 | + /// The same answer for the things that stand on the panel rather than on a | |
| 52 | + /// button. | |
| 53 | + pub const BG_HOVER_DIM: u32 = 0x1d2531; | |
| 54 | + /// A picked row, a picked clip: the accent at surface brightness, so a | |
| 55 | + /// selection is tinted rather than lit up. | |
| 56 | + pub const BG_SELECTED: u32 = 0x0d4b5c; | |
| 57 | + /// What a card is floated over when it is genuinely modal (the export, the | |
| 58 | + /// actions list). Inspector sections never draw one -- they occlude nothing. | |
| 59 | + pub const SCRIM: u32 = 0x0b0d10cc; | |
| 60 | + /// The lighter scrim: the picker list floats over a card that is still being | |
| 61 | + /// read, so it dims rather than hides. | |
| 62 | + pub const SCRIM_LIGHT: u32 = 0x0b0d1055; | |
| 63 | + | |
| 64 | + // -- strokes ---------------------------------------------------------------- | |
| 65 | + pub const STROKE_DIVIDER: u32 = 0x2a3442; | |
| 66 | + /// The keyboard's own ring, distinct from selection on purpose: focus is | |
| 67 | + /// where the next stroke lands, selection is what an edit acts on. | |
| 68 | + pub const STROKE_FOCUS: u32 = 0xffd166; | |
| 69 | + pub const STROKE_SELECTED: u32 = 0x22d3ee; | |
| 70 | + | |
| 71 | + // -- text ------------------------------------------------------------------- | |
| 72 | + pub const FG_PRIMARY: u32 = 0xe9eff7; | |
| 73 | + /// Shortcuts, dismissal hints, detail lines. Past 4.5:1 on every surface | |
| 74 | + /// above. | |
| 75 | + pub const FG_SECONDARY: u32 = 0xa7b6c9; | |
| 76 | + pub const FG_DISABLED: u32 = 0x6c7a8b; | |
| 77 | + | |
| 78 | + // -- interaction ------------------------------------------------------------ | |
| 79 | + pub const ACCENT_PRIMARY: u32 = 0x22d3ee; | |
| 80 | + /// The accent under the pointer: lighter, still the accent. | |
| 81 | + pub const ACCENT_HOVER: u32 = 0x67e8f9; | |
| 82 | + /// Not the accent: the playhead crosses every clip colour there is and has | |
| 83 | + /// to stay the one line that is none of them. | |
| 84 | + pub const ACCENT_PLAYHEAD: u32 = 0xff9db0; | |
| 85 | + /// The accent as a translucent wash, for the marks drawn over a clip body. | |
| 86 | + pub const ACCENT_WASH: u32 = 0x22d3eeaa; | |
| 87 | + | |
| 88 | + // -- clip kinds (cross-NLE convention) -------------------------------------- | |
| 89 | + pub const CLIP_VIDEO: u32 = 0x2b5fa8; | |
| 90 | + pub const CLIP_AUDIO: u32 = 0x276b43; | |
| 91 | + pub const CLIP_IMAGE: u32 = 0x1a6a6a; | |
| 92 | + pub const CLIP_TEXT: u32 = 0x6b46c1; | |
| 93 | + | |
| 94 | + /// One per source, so a clip that came from an imported file reads as coming | |
| 95 | + /// from somewhere else than its neighbour. The *kind* is the body colour now | |
| 96 | + /// ([`super::clip_kind`]); this is the identity stripe and the library | |
| 97 | + /// swatch, and it only has to be four things telling each other apart. | |
| 98 | + pub const SOURCE_TINTS: [u32; 4] = [0x4f8fd6, 0xd69a4f, 0x4fd6a8, 0xb14fd6]; | |
| 99 | + | |
| 100 | + // -- feedback --------------------------------------------------------------- | |
| 101 | + pub const STATUS_ERROR: u32 = 0xef4444; | |
| 102 | + pub const STATUS_WARNING: u32 = 0xf59e0b; | |
| 103 | + pub const STATUS_SUCCESS: u32 = 0x34d399; | |
| 104 | + pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY; | |
| 105 | + /// The mirror of [`BG_SELECTED`]: a drop the lane will not take, tinting the | |
| 106 | + /// shadow the drag draws so a refusal is seen before the release. | |
| 107 | + pub const DROP_REFUSE: u32 = 0x8f2740; | |
| 108 | + | |
| 109 | + // -- subtitles (drawn over the picture, so they own their own contrast) ----- | |
| 110 | + pub const SUB_FG: u32 = 0xffffff; | |
| 111 | + pub const SUB_SHADE: u32 = 0x000000cc; | |
| 112 | + | |
| 113 | + // -- the equalizer graph and the histogram ---------------------------------- | |
| 114 | + pub const EQ_GRID: u32 = 0x2a3442; | |
| 115 | + pub const EQ_SPECTRUM_INK: u32 = 0x7f95ad66; | |
| 116 | + pub const EQ_FILL_INK: u32 = 0x22d3ee26; | |
| 117 | + pub const EQ_BELL_INK: u32 = 0x22d3ee66; | |
| 118 | + pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0]; | |
| 119 | +} | |
| 120 | + | |
| 121 | +/// Family A: a warm consumer-editor ground (Movavi's bed, CapCut's saturation) | |
| 122 | +/// with one coral accent that is never used for anything but "this is live, | |
| 123 | +/// press this". Same roles, same measured floors, different numbers. | |
| 124 | +pub mod warm { | |
| 125 | + // -- surfaces --------------------------------------------------------------- | |
| 126 | + pub const BG_CANVAS: u32 = 0x0c0a09; | |
| 127 | + pub const BG_PANEL: u32 = 0x1d1917; | |
| 128 | + pub const BG_RAISED: u32 = 0x383029; | |
| 129 | + pub const BG_TIMELINE: u32 = 0x151211; | |
| 130 | + pub const BG_HOVER: u32 = 0x4a413b; | |
| 131 | + pub const BG_HOVER_DIM: u32 = 0x241f1d; | |
| 132 | + /// Darker than the family it came from: at V3's own `0x7a3a1c` the secondary | |
| 133 | + /// ink on a picked row measures 4.09:1 and WCAG 1.4.3 wants 4.5, which the | |
| 134 | + /// cool table's guard caught the moment this became a second palette. | |
| 135 | + pub const BG_SELECTED: u32 = 0x6a3118; | |
| 136 | + pub const SCRIM: u32 = 0x0c0a09cc; | |
| 137 | + pub const SCRIM_LIGHT: u32 = 0x0c0a0955; | |
| 138 | + | |
| 139 | + // -- strokes ---------------------------------------------------------------- | |
| 140 | + pub const STROKE_DIVIDER: u32 = 0x3a322e; | |
| 141 | + pub const STROKE_FOCUS: u32 = 0xffc38a; | |
| 142 | + pub const STROKE_SELECTED: u32 = ACCENT_PRIMARY; | |
| 143 | + | |
| 144 | + // -- text ------------------------------------------------------------------- | |
| 145 | + pub const FG_PRIMARY: u32 = 0xf2ece6; | |
| 146 | + pub const FG_SECONDARY: u32 = 0xbdb1a8; | |
| 147 | + pub const FG_DISABLED: u32 = 0x8a7f78; | |
| 148 | + | |
| 149 | + // -- interaction ------------------------------------------------------------ | |
| 150 | + pub const ACCENT_PRIMARY: u32 = 0xff7a45; | |
| 151 | + pub const ACCENT_HOVER: u32 = 0xff9a6e; | |
| 152 | + /// Warmer still than the accent, because it crosses everything the accent is | |
| 153 | + /// drawn on and has to stay findable over a selected clip. | |
| 154 | + pub const ACCENT_PLAYHEAD: u32 = 0xffc23a; | |
| 155 | + pub const ACCENT_WASH: u32 = 0xff7a45aa; | |
| 156 | + | |
| 157 | + // -- clip kinds (the same cross-NLE convention, at this family's weight) ---- | |
| 158 | + pub const CLIP_VIDEO: u32 = 0x2b4c7e; | |
| 159 | + pub const CLIP_AUDIO: u32 = 0x2c5a3a; | |
| 160 | + pub const CLIP_IMAGE: u32 = 0x1f5560; | |
| 161 | + pub const CLIP_TEXT: u32 = 0x4a3070; | |
| 162 | + | |
| 163 | + /// Warm-side identity stripes: the same four-way distinctness the cool | |
| 164 | + /// family's are held to, in hues that belong to this ground. | |
| 165 | + pub const SOURCE_TINTS: [u32; 4] = [0xe08a4f, 0x4fa8d6, 0x8fc94f, 0xd67aa8]; | |
| 166 | + | |
| 167 | + // -- feedback --------------------------------------------------------------- | |
| 168 | + pub const STATUS_ERROR: u32 = 0xc85050; | |
| 169 | + pub const STATUS_WARNING: u32 = 0xe0a53a; | |
| 170 | + pub const STATUS_SUCCESS: u32 = 0x4fbf72; | |
| 171 | + pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY; | |
| 172 | + pub const DROP_REFUSE: u32 = 0x8a2f24; | |
| 173 | + | |
| 174 | + // -- subtitles -------------------------------------------------------------- | |
| 175 | + pub const SUB_FG: u32 = 0xffffff; | |
| 176 | + pub const SUB_SHADE: u32 = 0x000000cc; | |
| 177 | + | |
| 178 | + // -- the equalizer graph and the histogram ---------------------------------- | |
| 179 | + pub const EQ_GRID: u32 = 0x4a413b; | |
| 180 | + pub const EQ_SPECTRUM_INK: u32 = 0xbdb1a866; | |
| 181 | + pub const EQ_FILL_INK: u32 = 0xff7a4526; | |
| 182 | + pub const EQ_BELL_INK: u32 = 0xff7a4566; | |
| 183 | + pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0]; | |
| 184 | +} | |
| 185 | + | |
| 186 | +/// The box a button's glyph sits in, whatever the glyph happens to measure: the | |
| 187 | +/// pause bars are 12 px wide and the play triangle 11, and a button that resized | |
| 188 | +/// itself when it was pressed moved every button to its right. | |
| 189 | +pub const GLYPH_SLOT: f32 = 14.; | |
| 190 | + | |
| 191 | +/// How solid the shadow a drag draws is (`0xRRGGBBAA`): enough to read as a box, | |
| 192 | +/// little enough that the clip under it is still legible. Not a colour, so both | |
| 193 | +/// families share it. | |
| 194 | +pub const GHOST_ALPHA: u32 = 0x66; | |
| 65 | 195 | |
| 66 | 196 | /// What a clip on `kind` is painted: the timeline's whole colour language in |
| 67 | 197 | /// one call, so a lane added later cannot invent a shade of its own. |
| @@ -73,17 +203,6 @@ pub const fn clip_kind(kind: LaneKind, image: bool) -> u32 { | ||
| 73 | 203 | } |
| 74 | 204 | } |
| 75 | 205 | |
| 76 | -/// One per source, so a clip that came from an imported file reads as coming | |
| 77 | -/// from somewhere else than its neighbour. The *kind* is the body colour now | |
| 78 | -/// ([`clip_kind`]); this is the identity stripe and the library swatch, and it | |
| 79 | -/// only has to be four things telling each other apart. | |
| 80 | -pub const SOURCE_TINTS: [u32; 4] = [0x4f8fd6, 0xd69a4f, 0x4fd6a8, 0xb14fd6]; | |
| 81 | - | |
| 82 | -// -- feedback ----------------------------------------------------------------- | |
| 83 | -pub const STATUS_ERROR: u32 = 0xef4444; | |
| 84 | -pub const STATUS_WARNING: u32 = 0xf59e0b; | |
| 85 | -pub const STATUS_SUCCESS: u32 = 0x34d399; | |
| 86 | -pub const STATUS_PROGRESS: u32 = ACCENT_PRIMARY; | |
| 87 | 206 | /// Which of the feedback colours a message wears. Read off the words rather |
| 88 | 207 | /// than carried alongside them: every message in this editor already opens with |
| 89 | 208 | /// what it is ("EXPORT DONE", "SCAN FAILED", "NOTHING DETACHED"), and a second |
| @@ -106,24 +225,6 @@ pub fn notice_tone(message: &str) -> u32 { | ||
| 106 | 225 | } |
| 107 | 226 | } |
| 108 | 227 | |
| 109 | -/// The mirror of [`BG_SELECTED`]: a drop the lane will not take, tinting the | |
| 110 | -/// shadow the drag draws so a refusal is seen before the release. | |
| 111 | -pub const DROP_REFUSE: u32 = 0x8f2740; | |
| 112 | -/// How solid that shadow is (`0xRRGGBBAA`): enough to read as a box, little | |
| 113 | -/// enough that the clip under it is still legible. | |
| 114 | -pub const GHOST_ALPHA: u32 = 0x66; | |
| 115 | - | |
| 116 | -// -- subtitles (drawn over the picture, so they own their own contrast) -------- | |
| 117 | -pub const SUB_FG: u32 = 0xffffff; | |
| 118 | -pub const SUB_SHADE: u32 = 0x000000cc; | |
| 119 | - | |
| 120 | -// -- the equalizer graph and the histogram ------------------------------------ | |
| 121 | -pub const EQ_GRID: u32 = 0x2a3442; | |
| 122 | -pub const EQ_SPECTRUM_INK: u32 = 0x7f95ad66; | |
| 123 | -pub const EQ_FILL_INK: u32 = 0x22d3ee26; | |
| 124 | -pub const EQ_BELL_INK: u32 = 0x22d3ee66; | |
| 125 | -pub const HIST_INK: [u32; 3] = [0xE0_5A_5A, 0x5A_D0_7A, 0x5A_9A_E0]; | |
| 126 | - | |
| 127 | 228 | // -- geometry the four regions are laid out on -------------------------------- |
| 128 | 229 | /// Compact density: 11-13 px text, 28 px controls, 8 px gutters. The floor the |
| 129 | 230 | /// whole window is measured at is 640x360, and airy spacing loses a region. |
| @@ -136,6 +237,3 @@ pub const INSPECTOR_FRAC: f32 = 0.24; | ||
| 136 | 237 | pub fn inspector_w(window_w: f32) -> f32 { |
| 137 | 238 | (window_w * INSPECTOR_FRAC).clamp(INSPECTOR_MIN_W, INSPECTOR_MAX_W) |
| 138 | 239 | } |
| 139 | -/// The lighter scrim: the picker list floats over a card that is still being | |
| 140 | -/// read, so it dims rather than hides. | |
| 141 | -pub const SCRIM_LIGHT: u32 = 0x0b0d1055; |
crates/app/src/ui/toolbar.rsmodified+3 -0
| @@ -249,6 +249,7 @@ impl Player { | ||
| 249 | 249 | .items_center() |
| 250 | 250 | .gap(px(8.)) |
| 251 | 251 | .overflow_x_scroll() |
| 252 | + .child(group_label("Edit")) | |
| 252 | 253 | .child(self.action_control( |
| 253 | 254 | "cut", |
| 254 | 255 | 0., |
| @@ -280,6 +281,7 @@ impl Player { | ||
| 280 | 281 | cx.listener(|this, _: &ClickEvent, _, cx| this.undo(cx)), |
| 281 | 282 | )) |
| 282 | 283 | .child(separator()) |
| 284 | + .child(group_label("Track")) | |
| 283 | 285 | .child(self.action_control( |
| 284 | 286 | "add-video-lane", |
| 285 | 287 | 0., |
| @@ -317,6 +319,7 @@ impl Player { | ||
| 317 | 319 | }), |
| 318 | 320 | )) |
| 319 | 321 | .child(separator()) |
| 322 | + .child(group_label("View")) | |
| 320 | 323 | // Both toggles keep a rect of their own: the label is the |
| 321 | 324 | // state, and a state that resized its own button is what |
| 322 | 325 | // made the row shuffle every time it was pressed. |
crates/app/src/ui/widgets.rsmodified+33 -2
| @@ -73,13 +73,33 @@ pub(crate) fn control( | ||
| 73 | 73 | .rounded(px(4.)) |
| 74 | 74 | .bg(rgb(bg)) |
| 75 | 75 | .when(bg == ACCENT_PRIMARY, |d| d.text_color(rgb(BG_CANVAS))) |
| 76 | - .children(glyph) | |
| 76 | + // A glyph sits in a box of its own width, never in the width it happens | |
| 77 | + // to draw: the pause bars are 12 px wide and the play triangle is 11, so | |
| 78 | + // pressing Play used to slide every button in the row one pixel left. A | |
| 79 | + // slot is the only fix that holds for the next glyph as well as this one. | |
| 80 | + .children(glyph.map(|glyph| { | |
| 81 | + div() | |
| 82 | + .flex_none() | |
| 83 | + .w(px(GLYPH_SLOT)) | |
| 84 | + .flex() | |
| 85 | + .items_center() | |
| 86 | + .justify_center() | |
| 87 | + .child(glyph) | |
| 88 | + })) | |
| 77 | 89 | .child(label) |
| 78 | 90 | .tooltip(move |_, cx| cx.new(|_| Tip(tip.clone())).into()) |
| 79 | 91 | .when(!enabled, |d| d.opacity(0.4).cursor_not_allowed()) |
| 80 | 92 | .when(enabled, |d| { |
| 93 | + // An accented button keeps its accent under the pointer: hovering it | |
| 94 | + // to the chrome's own hover colour reads as the primary action | |
| 95 | + // turning itself off. | |
| 81 | 96 | d.cursor_pointer() |
| 82 | - .hover(|s| s.bg(rgb(BG_HOVER))) | |
| 97 | + .hover(move |s| { | |
| 98 | + s.bg(rgb(match bg == ACCENT_PRIMARY { | |
| 99 | + true => ACCENT_HOVER, | |
| 100 | + false => BG_HOVER, | |
| 101 | + })) | |
| 102 | + }) | |
| 83 | 103 | .on_click(on_click) |
| 84 | 104 | }) |
| 85 | 105 | } |
| @@ -138,6 +158,17 @@ pub(crate) fn volume_slider( | ||
| 138 | 158 | } |
| 139 | 159 | |
| 140 | 160 | /// The line between two groups of buttons. |
| 161 | +/// What a group of buttons is *for*, printed in front of it. A toolbar of | |
| 162 | +/// twelve unlabelled boxes is a toolbar nobody reads twice; three named groups | |
| 163 | +/// are three things to skip. | |
| 164 | +pub(crate) fn group_label(name: &'static str) -> impl IntoElement { | |
| 165 | + div() | |
| 166 | + .flex_none() | |
| 167 | + .text_size(px(10.)) | |
| 168 | + .text_color(rgb(FG_SECONDARY)) | |
| 169 | + .child(name) | |
| 170 | +} | |
| 171 | + | |
| 141 | 172 | pub(crate) fn separator() -> impl IntoElement { |
| 142 | 173 | div() |
| 143 | 174 | .flex_none() |