forge
Explore
Log in

Don't you dare go Hollow

The monitoring level lives in Settings — a row, a wheel and `m`

Browse files at this commit

034b772a07f1da235d31bb0549dd16cadfdbacd8Ahmet Kaan GümüşParent: 0a1b19d
  • feat
    • the monitoring level lives in Settings — a row, a wheel and `m`
Show full message
✨ feat(app): the monitoring level lives in Settings — a row, a wheel and `m`

Cleanse round 2 took mute, `− +` and the slider off the time band on
DESIGN §5's promise that the level lives in Settings; nothing kept it
until now, which is why ToggleMute/VolumeUp/VolumeDown sat in the
widget-home guard's exemption list.

EDITOR's first row is `Level`: the level in mono (`muted`, in the quieter
ink, when it is being held silent), the mute chord beside it, and the
wheel over the row moving it a key press at a time through the same two
actions the keys dispatch. No slider — the number is spent rarely.

The three strokes are answered in the settings key branch rather than
left to the keymap: this page counts as a card, so the darkroom's modal
guard swallowed `m` entirely while it was the visible thing on screen
(caught in the harness, now guarded). Session-only: nothing in
~/.config/edith holds a level.
crates/app/src/player/cards.rsmodified+11 -0
@@ -1836,6 +1836,17 @@ impl Player {
1836 "c" => self.cycle_export_picture(),1836 "c" => self.cycle_export_picture(),
1837 "b" => self.cycle_audio_kbps(),1837 "b" => self.cycle_audio_kbps(),
1838 "g" => self.cycle_encoder(cx),1838 "g" => self.cycle_encoder(cx),
1839+ // The Level row's own three, and they have to be *here*:
1840+ // this page counts as a card in [`Self::card_open`], so a
1841+ // stroke that falls through this branch is swallowed by the
1842+ // darkroom's modal guard rather than reaching the keymap --
1843+ // `m` did nothing at all with the page up (caught in the
1844+ // harness, not by a guard). Same setter the keymap's
1845+ // [`ActionId::ToggleMute`]/`VolumeUp`/`VolumeDown` call, so
1846+ // the row cannot drift from the chord it wears.
1847+ "m" => self.set_volume(|volume| volume.muted = !volume.muted, cx),
1848+ "=" => self.set_volume(|volume| volume.step(true), cx),
1849+ "-" => self.set_volume(|volume| volume.step(false), cx),
1839 _ => return false,1850 _ => return false,
1840 }1851 }
1841 return true;1852 return true;
crates/app/src/tests/layout.rsmodified+100 -12
@@ -2544,18 +2544,6 @@ fn every_action_has_a_darkroom_widget_home_or_explicit_owner() {
2544 ActionId::Loop,2544 ActionId::Loop,
2545 "KEYS tab + key: the loop toggle left the band in cleanse round 2",2545 "KEYS tab + key: the loop toggle left the band in cleanse round 2",
2546 ),2546 ),
2547- (
2548- ActionId::ToggleMute,
2549- "KEYS tab + key: the monitoring cluster left the band in cleanse round 2",
2550- ),
2551- (
2552- ActionId::VolumeUp,
2553- "KEYS tab + key: the monitoring cluster left the band in cleanse round 2",
2554- ),
2555- (
2556- ActionId::VolumeDown,
2557- "KEYS tab + key: the monitoring cluster left the band in cleanse round 2",
2558- ),
2559 (2547 (
2560 ActionId::ClearRange,2548 ActionId::ClearRange,
2561 "KEYS tab + key: `I O ×` left the band in cleanse round 2 -- in and out \2549 "KEYS tab + key: `I O ×` left the band in cleanse round 2 -- in and out \
@@ -3865,3 +3853,103 @@ fn no_region_root_wears_a_focus_ring() {
3865 }3853 }
3866 }3854 }
3867 }3855 }
3856+
3857+
3858+/// The monitoring level's home. Cleanse round 2 took the mute button, the
3859+/// `- +` pair and the slider off the time band on the promise that the level
3860+/// "lives in Settings" (DESIGN 5) -- a promise nothing kept until this row,
3861+/// which is why the volume trio sat in
3862+/// [`every_action_has_a_darkroom_widget_home_or_explicit_owner`]'s exemption
3863+/// list. A source scan, like every other guard on this page: the EDITOR
3864+/// section carries the row, the row wears the mute chord (`m`), and the wheel
3865+/// over it moves the level through the very actions the keys do -- no second
3866+/// setter, no slider growing back.
3867+#[test]
3868+fn the_editor_section_owns_the_monitoring_level_row() {
3869+ let source = src_text("ui/settings_stance.rs");
3870+ let editor_start = source
3871+ .find("fn editor_section(")
3872+ .expect("the editor section");
3873+ let render_start = source
3874+ .find("pub(crate) fn render(")
3875+ .expect("the page's render fn");
3876+ let editor_body = &source[editor_start..render_start];
3877+ for needle in [
3878+ "\"settings-level\"",
3879+ "\"Level\"",
3880+ "ActionId::ToggleMute",
3881+ "ActionId::VolumeUp",
3882+ "ActionId::VolumeDown",
3883+ ".on_scroll_wheel(",
3884+ ] {
3885+ assert!(
3886+ editor_body.contains(needle),
3887+ "the EDITOR section's Level row is missing {needle}"
3888+ );
3889+ }
3890+ // The chord the row draws is the keymap's own, so the badge reads `m`
3891+ // wherever this test's reader looks for it.
3892+ assert_eq!(
3893+ crate::keymap::Keymap::defaults().chord(crate::ActionId::ToggleMute),
3894+ "m",
3895+ "the mute chord moved -- the Level row's badge is no longer `m`"
3896+ );
3897+ // Muted reads as a word in the quieter ink, never as `0%`: the level is
3898+ // what unmuting comes back to and the row must not lie about it.
3899+ assert!(
3900+ editor_body.contains("\"muted\".to_string()"),
3901+ "the Level row must say `muted` rather than a number when silenced"
3902+ );
3903+ // A readout, not a widget: the slider stayed dead (DESIGN 5).
3904+ assert!(
3905+ !editor_body.contains("volume_bar") && !editor_body.contains("drag_volume"),
3906+ "the level slider grew back in Settings"
3907+ );
3908+ // The page counts as a card ([`Player::card_open`]), so the darkroom's
3909+ // modal guard eats every stroke this branch does not answer: without
3910+ // these three arms the row wears a chord that does nothing while the page
3911+ // is the visible thing on screen (what the first harness run showed).
3912+ let cards = src_text("player/cards.rs");
3913+ let branch_start = cards
3914+ .find("if self.settings_open {")
3915+ .expect("the settings key branch");
3916+ let branch = &cards[branch_start..(branch_start + 1600).min(cards.len())];
3917+ for arm in ["\"m\" =>", "\"=\" =>", "\"-\" =>"] {
3918+ assert!(
3919+ branch.contains(arm),
3920+ "the settings key branch does not answer {arm} -- the Level row's \
3921+ chord is swallowed by the modal guard while the page is up"
3922+ );
3923+ }
3924+}
3925+
3926+/// The wheel's own arithmetic: one notch is one key press (5%), and the count
3927+/// stops at both ends rather than wrapping silence into full volume -- the
3928+/// saturating pair [`Volume::step`] is written for. Pure, so it runs without
3929+/// a window.
3930+#[test]
3931+fn the_level_wheel_steps_five_percent_and_clamps_at_both_ends() {
3932+ use crate::transport::Volume;
3933+ let mut volume = Volume::default();
3934+ assert_eq!(volume.percent(), 100);
3935+ for expected in [95, 90, 85, 80] {
3936+ volume.step(false);
3937+ assert_eq!(volume.percent(), expected, "a notch down is 5%");
3938+ }
3939+ for _ in 0..40 {
3940+ volume.step(false);
3941+ }
3942+ assert_eq!(volume.percent(), 0, "the level floors at silence");
3943+ volume.step(false);
3944+ assert_eq!(volume.percent(), 0, "a notch below silence is silence");
3945+ for _ in 0..40 {
3946+ volume.step(true);
3947+ }
3948+ assert_eq!(volume.percent(), 100, "the level ceilings at full");
3949+ volume.step(true);
3950+ assert_eq!(volume.percent(), 100, "a notch above full is full");
3951+ // Turning it down while muted is not what makes sound come out.
3952+ volume.muted = true;
3953+ volume.step(false);
3954+ assert!(volume.muted && volume.percent() == 95);
3955+}
crates/app/src/transport.rsmodified+8 -1
@@ -77,12 +77,19 @@ impl Volume {
77 f32::from(self.steps) / f32::from(Self::MAX_STEPS)77 f32::from(self.steps) / f32::from(Self::MAX_STEPS)
78 }78 }
79 79
80+ /// The level as a number to read out, 0..=100 -- what the settings page's
81+ /// Level row says (`100%`), the one place the level is written since the
82+ /// time band lost its slider.
83+ pub(crate) fn percent(self) -> u32 {
84+ u32::from(self.steps) * 100 / u32::from(Self::MAX_STEPS)
85+ }
86+
80 /// What the button read before the mute state became a glyph and a colour87 /// What the button read before the mute state became a glyph and a colour
81 /// ([`Player::toolbar`]): the guards still hold the wording to it, so it88 /// ([`Player::toolbar`]): the guards still hold the wording to it, so it
82 /// sits with them rather than in the binary.89 /// sits with them rather than in the binary.
83 #[cfg(test)]90 #[cfg(test)]
84 pub(crate) fn label(self) -> String {91 pub(crate) fn label(self) -> String {
85- let percent = u32::from(self.steps) * 100 / u32::from(Self::MAX_STEPS);92+ let percent = self.percent();
86 if self.muted {93 if self.muted {
87 format!("Muted {percent}%")94 format!("Muted {percent}%")
88 } else {95 } else {
crates/app/src/ui/settings_stance.rsmodified+53 -0
@@ -406,6 +406,59 @@ fn editor_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElement
406 .flex_col()406 .flex_col()
407 .gap(px(2.))407 .gap(px(2.))
408 .child(section_head("EDITOR · this machine, this window"))408 .child(section_head("EDITOR · this machine, this window"))
409+ // The monitoring level, which lost its slider when the time band was
410+ // cleansed (DESIGN §5 -- "the level lives in Settings"). A readout and
411+ // not a widget: the number is spent rarely, so the wheel over the row
412+ // moves it and `m` silences it, exactly what the keys already do
413+ // ([`ActionId::VolumeUp`]/[`ActionId::VolumeDown`] reach the same
414+ // setter while this page is up, since the settings key branch passes
415+ // every stroke but its own three through to the keymap). Session-only:
416+ // nothing in ~/.config/edith holds a level, and a muted window that
417+ // stayed muted across a launch is a bug report, not a preference.
418+ .child(
419+ div()
420+ .id("settings-level-wheel")
421+ .flex_none()
422+ .on_scroll_wheel(cx.listener(
423+ |this, event: &ScrollWheelEvent, window, cx| {
424+ let by = wheel_delta(event);
425+ if by == 0. {
426+ return;
427+ }
428+ // One notch is one press: the wheel lands on the same
429+ // 5% grid the keys do, never a second finer one.
430+ this.act(
431+ if by > 0. {
432+ ActionId::VolumeUp
433+ } else {
434+ ActionId::VolumeDown
435+ },
436+ window,
437+ cx,
438+ );
439+ cx.stop_propagation();
440+ },
441+ ))
442+ .child(row_full(
443+ "settings-level",
444+ "Level",
445+ match player.volume.muted {
446+ true => "muted".to_string(),
447+ false => format!("{}%", player.volume.percent()),
448+ },
449+ "Monitoring level -- the wheel over this row moves it 5% at a time; kept for this window, never written into a project",
450+ Some(player.keymap.chord(ActionId::ToggleMute).into()),
451+ None,
452+ player,
453+ cx.listener(|this, _: &ClickEvent, _, cx| {
454+ this.set_volume(|volume| volume.muted = !volume.muted, cx)
455+ }),
456+ match player.volume.muted {
457+ true => INK3(),
458+ false => INK1(),
459+ },
460+ )),
461+ )
409 .child(row_keyed(462 .child(row_keyed(
410 "settings-proxies",463 "settings-proxies",
411 "Proxies",464 "Proxies",