forge
Explore
Log in

Don't you dare go Hollow

Guard focus ring to darkroom + ctrl-click uses press modifiers

Browse files at this commit

6da98cd907df1a810bbc56fb1ab84f34070a1ccfAhmet Kaan GümüşParent: 93dd61d
  • fix
    • guard focus ring to darkroom + ctrl-click uses press modifiers
Show full message
🐛 fix(ui): guard focus ring to darkroom + ctrl-click uses press modifiers

FocusPanels (F6) called window.focus on the ring's handles even under
OLD_GUI=1, where the legacy tree never mounts them -- an unmounted focus
target kills all key dispatch until a mouse click. focus_surface now
no-ops when !self.darkroom, the single door every route goes through.

ClickEvent::modifiers() answers the mouse-up modifiers, so releasing
ctrl before the button undid a ctrl-held toggle decided on mouse-down
(clip_box/sub_box in bench_stance.rs, timeline.rs's two clip boxes).
Added widgets::press_modifiers, reading ClickEvent::Mouse's down event
instead, at all four sites.

Also: dock_stance.rs's doc comments were swapped between transition_row
and clip_tab -- moved each back to its own fn; the transition steppers'
hitmap labels were the raw element id instead of a phrase, given
"Shorten transition"/"Lengthen transition"; and view.rs's stale comment
referencing the old window.focus(&self.focus_dock) call updated to
name focus_surface.
crates/app/src/tests/view.rsmodified+3 -3
@@ -968,9 +968,9 @@ fn escape_is_the_only_key_a_focused_surface_uses_to_leave_the_ring() {
968 }968 }
969 969
970 /// [`ActionId::FocusPanels`] is what starts the ring in the first place970 /// [`ActionId::FocusPanels`] is what starts the ring in the first place
971-/// (`Player::act`'s `window.focus(&self.focus_dock)`) -- without a bound key971+/// (`Player::act`'s `self.focus_surface(Surface::Dock, ..)`) -- without a
972-/// reaching it, `next_surface`/`is_focus_cycle_key` above are unreachable972+/// bound key reaching it, `next_surface`/`is_focus_cycle_key` above are
973-/// dead code, exactly the defect this action closes.973+/// unreachable dead code, exactly the defect this action closes.
974 #[test]974 #[test]
975 fn focus_panels_is_bound_and_lands_on_the_dock() {975 fn focus_panels_is_bound_and_lands_on_the_dock() {
976 use keymap::{ActionId, Keymap};976 use keymap::{ActionId, Keymap};
crates/app/src/ui/bench_stance.rsmodified+2 -2
@@ -288,7 +288,7 @@ fn clip_box(
288 // the press so a set-drag has something to move; this is where the288 // the press so a set-drag has something to move; this is where the
289 // collapse a plain click promises actually lands.289 // collapse a plain click promises actually lands.
290 .on_click(cx.listener(move |this, event: &ClickEvent, _, cx| {290 .on_click(cx.listener(move |this, event: &ClickEvent, _, cx| {
291- if !event.modifiers().control {291+ if !press_modifiers(event).control {
292 this.select((lane, idx), cx);292 this.select((lane, idx), cx);
293 }293 }
294 }))294 }))
@@ -672,7 +672,7 @@ fn sub_box(
672 // A plain click collapses a multi-pick to this one, exactly as a672 // A plain click collapses a multi-pick to this one, exactly as a
673 // clip's own box does -- see the comment there.673 // clip's own box does -- see the comment there.
674 .on_click(cx.listener(move |this, event: &ClickEvent, _, cx| {674 .on_click(cx.listener(move |this, event: &ClickEvent, _, cx| {
675- if !event.modifiers().control {675+ if !press_modifiers(event).control {
676 this.select((lane, idx), cx);676 this.select((lane, idx), cx);
677 }677 }
678 }))678 }))
crates/app/src/ui/dock_stance.rsmodified+11 -11
@@ -1077,13 +1077,6 @@ fn sources_tab(
1077 })1077 })
1078 }1078 }
1079 1079
1080-/// The Clip tab: the four verbs DESIGN §5 names, as ghosts, over whichever
1081-/// param-row card they open -- [`Player::eq_card`], [`Player::color_card`],
1082-/// [`Player::transform_card`], [`Player::speed_card`] verbatim, the same
1083-/// param-row rendering `inspector.rs`'s selection section already opens
1084-/// these onto. Drag-while-playing and every other gesture on a row is
1085-/// whatever that card already does; nothing about the gesture is reimplemented
1086-/// here.
1087 /// The transition duration row, in the darkroom's own idiom: the darkroom is1080 /// The transition duration row, in the darkroom's own idiom: the darkroom is
1088 /// the default surface (`main.rs`'s `OLD_GUI` gate), so a row that only ever1081 /// the default surface (`main.rs`'s `OLD_GUI` gate), so a row that only ever
1089 /// drew in the legacy inspector (`ui::inspector::transition_duration_row`)1082 /// drew in the legacy inspector (`ui::inspector::transition_duration_row`)
@@ -1099,7 +1092,7 @@ fn transition_row(player: &Player, cx: &mut Context<Player>) -> Option<impl Into
1099 let (label_text, frames, cap) =1092 let (label_text, frames, cap) =
1100 crate::ui::inspector::transition_of(lane.kind, clips.get(idx)?, clips.get(idx + 1))?;1093 crate::ui::inspector::transition_of(lane.kind, clips.get(idx)?, clips.get(idx + 1))?;
1101 let label_style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM);1094 let label_style = label(type_scale::LABEL_ROW_PX, FontWeight::MEDIUM);
1102- let step = |id: &'static str, glyph: &'static str, by: i32, cx: &mut Context<Player>| {1095+ let step = |id: &'static str, label: &'static str, glyph: &'static str, by: i32, cx: &mut Context<Player>| {
1103 div()1096 div()
1104 .id(id)1097 .id(id)
1105 .flex()1098 .flex()
@@ -1111,7 +1104,7 @@ fn transition_row(player: &Player, cx: &mut Context<Player>) -> Option<impl Into
1111 .bg(rgb(DARK_RAISED()))1104 .bg(rgb(DARK_RAISED()))
1112 .cursor_pointer()1105 .cursor_pointer()
1113 .hover(|s| s.text_color(rgb(INK1())))1106 .hover(|s| s.text_color(rgb(INK1())))
1114- .children(hitmap::control(id, id, true))1107+ .children(hitmap::control(id, label, true))
1115 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {1108 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
1116 this.nudge_transition(lane, idx, by, cx);1109 this.nudge_transition(lane, idx, by, cx);
1117 }))1110 }))
@@ -1133,11 +1126,18 @@ fn transition_row(player: &Player, cx: &mut Context<Player>) -> Option<impl Into
1133 .text_color(rgb(INK2()))1126 .text_color(rgb(INK2()))
1134 .child(format!("{label_text} {frames}f (of {cap}f offered)")),1127 .child(format!("{label_text} {frames}f (of {cap}f offered)")),
1135 )1128 )
1136- .child(step("transition-minus", "−", -1, cx))1129+ .child(step("transition-minus", "Shorten transition", "−", -1, cx))
1137- .child(step("transition-plus", "+", 1, cx)),1130+ .child(step("transition-plus", "Lengthen transition", "+", 1, cx)),
1138 )1131 )
1139 }1132 }
1140 1133
1134+/// The Clip tab: the four verbs DESIGN §5 names, as ghosts, over whichever
1135+/// param-row card they open -- [`Player::eq_card`], [`Player::color_card`],
1136+/// [`Player::transform_card`], [`Player::speed_card`] verbatim, the same
1137+/// param-row rendering `inspector.rs`'s selection section already opens
1138+/// these onto. Drag-while-playing and every other gesture on a row is
1139+/// whatever that card already does; nothing about the gesture is reimplemented
1140+/// here.
1141 fn clip_tab(1141 fn clip_tab(
1142 player: &Player,1142 player: &Player,
1143 width: f32,1143 width: f32,
crates/app/src/ui/stance.rsmodified+10 -0
@@ -99,12 +99,22 @@ impl Player {
99 /// exactly as the tab's own click does (`dock_stance::dock_tab`'s99 /// exactly as the tab's own click does (`dock_stance::dock_tab`'s
100 /// `on_click`), so the ring and a mouse click can't disagree about100 /// `on_click`), so the ring and a mouse click can't disagree about
101 /// which tab was last chosen.101 /// which tab was last chosen.
102+ ///
103+ /// The ring is darkroom-only UI -- the legacy tree never mounts
104+ /// `focus_dock`/`focus_bench`/`focus_inspector` (only `track_focus`
105+ /// sites live in this module and `dock_stance.rs`), so under
106+ /// `OLD_GUI=1` a `window.focus` here would land on an unmounted
107+ /// handle and kill the root key listener (`main.rs`'s fallback focus)
108+ /// until the next mouse click. No-op there instead.
102 pub(crate) fn focus_surface(109 pub(crate) fn focus_surface(
103 &mut self,110 &mut self,
104 surface: Surface,111 surface: Surface,
105 window: &mut Window,112 window: &mut Window,
106 cx: &mut Context<Self>,113 cx: &mut Context<Self>,
107 ) {114 ) {
115+ if !self.darkroom {
116+ return;
117+ }
108 if let Some(src_active) = surface_wants_src_active(surface) {118 if let Some(src_active) = surface_wants_src_active(surface) {
109 self.dock_src_active = src_active;119 self.dock_src_active = src_active;
110 crate::ui::dock_stance::save(src_active);120 crate::ui::dock_stance::save(src_active);
crates/app/src/ui/timeline.rsmodified+2 -2
@@ -1390,7 +1390,7 @@ impl Player {
1390 // starts, so this only fires on a press-release1390 // starts, so this only fires on a press-release
1391 // with no drag between.1391 // with no drag between.
1392 .on_click(cx.listener(move |this, event: &ClickEvent, _, cx| {1392 .on_click(cx.listener(move |this, event: &ClickEvent, _, cx| {
1393- if !event.modifiers().control {1393+ if !press_modifiers(event).control {
1394 this.select((lane, i), cx);1394 this.select((lane, i), cx);
1395 }1395 }
1396 }))1396 }))
@@ -1775,7 +1775,7 @@ impl Player {
1775 // A plain click collapses a multi-pick to this one1775 // A plain click collapses a multi-pick to this one
1776 // caption, exactly as a clip's own box does above.1776 // caption, exactly as a clip's own box does above.
1777 .on_click(cx.listener(move |this, event: &ClickEvent, _, cx| {1777 .on_click(cx.listener(move |this, event: &ClickEvent, _, cx| {
1778- if !event.modifiers().control {1778+ if !press_modifiers(event).control {
1779 this.select((lane, i), cx);1779 this.select((lane, i), cx);
1780 }1780 }
1781 }))1781 }))
crates/app/src/ui/widgets.rsmodified+12 -0
@@ -9,6 +9,18 @@ pub(crate) fn waveform(peaks: Arc<Vec<(f32, f32)>>, from: f64, to: f64) -> impl
9 waveform_ink(peaks, from, to, FG_SECONDARY())9 waveform_ink(peaks, from, to, FG_SECONDARY())
10 }10 }
11 11
12+/// `ClickEvent::modifiers()` answers the mouse-*up* modifiers (gpui-0.2.2
13+/// `interactive.rs`), so releasing ctrl before the button lands undoes a
14+/// ctrl-held toggle decided on mouse-down. This reads the *press* modifiers
15+/// instead -- the ones a ctrl-click decision (multi-pick, no collapse) was
16+/// actually made under.
17+pub(crate) fn press_modifiers(event: &ClickEvent) -> gpui::Modifiers {
18+ match event {
19+ ClickEvent::Mouse(m) => m.down.modifiers,
20+ ClickEvent::Keyboard(_) => gpui::Modifiers::default(),
21+ }
22+}
23+
12 /// As [`waveform`], but in a caller-picked ink rather than the fixed24 /// As [`waveform`], but in a caller-picked ink rather than the fixed
13 /// secondary foreground -- the darkroom bench's own audio clips draw their25 /// secondary foreground -- the darkroom bench's own audio clips draw their
14 /// envelope in the source's ink (DESIGN §5), which the legacy timeline never26 /// envelope in the source's ink (DESIGN §5), which the legacy timeline never