forge
Explore
Log in

Don't you dare go Hollow

Call bar — your line at the bottom of the main panel (name, voice line, ping→stats, mute/deafen/camera/share split buttons, leave) replaces the sidebar dock

Browse files at this commit

cf9648db726db3ef67e1fc2c05b23eba2ad71a3aAhmet Kaan GümüşParent: f6fdcc1
  • feat
    • call bar — your line at the bottom of the main panel (name, voice line, ping→stats, mute/deafen/camera/share split buttons, leave) replaces the sidebar dock
    • call_bar::view shared by app and YUMUSH_GALLERY=call
    • artifact twin in design/gallery.html#call
Show full message
✨ feat: call bar — your line at the bottom of the main panel (name, voice line, ping→stats, mute/deafen/camera/share split buttons, leave) replaces the sidebar dock; call_bar::view shared by app and YUMUSH_GALLERY=call; artifact twin in design/gallery.html#call
crates/client/design/gallery.htmlmodified+9 -3
@@ -22,7 +22,8 @@ body{padding:var(--space-xxl);overflow:hidden}
22 <script>22 <script>
23 const {w,icon,chev,toggle,row,opts,track,line,caption,bands,mount}=Yumush;23 const {w,icon,chev,toggle,row,opts,track,line,caption,bands,mount}=Yumush;
24 const STATES=['base','long','empty','many','gun','large','narrow','bad'];24 const STATES=['base','long','empty','many','gun','large','narrow','bad'];
25-const state=STATES.includes(location.hash.slice(1))?location.hash.slice(1):'base';25+const [page,hs]=location.hash.slice(1).includes(':')?location.hash.slice(1).split(':'):['parts',location.hash.slice(1)];
26+const state=STATES.includes(hs)?hs:'base';
26 const bad=state==='bad';27 const bad=state==='bad';
27 document.documentElement.dataset.theme=state==='gun'?'gun':'gece';28 document.documentElement.dataset.theme=state==='gun'?'gun':'gece';
28 if(state==='large')document.documentElement.style.fontSize='16px';29 if(state==='large')document.documentElement.style.fontSize='16px';
@@ -44,6 +45,11 @@ const controls=`<div class="col" style="gap:var(--space-md)"><div class="section
44 <div class="col" style="width:var(--size-sidebar)"><div class="index">Profile</div><div class="index on">Voice</div><div class="index">${name('Camera &amp; share')}</div></div></div>`;45 <div class="col" style="width:var(--size-sidebar)"><div class="index">Profile</div><div class="index on">Voice</div><div class="index">${name('Camera &amp; share')}</div></div></div>`;
45 const pop=`<div class="popover" style="width:var(--size-popover);gap:var(--space-sm)"><div class="section">Microphone</div>${w('Shure MV7')}${w('Laptop mic','dim')}46 const pop=`<div class="popover" style="width:var(--size-popover);gap:var(--space-sm)"><div class="section">Microphone</div>${w('Shure MV7')}${w('Laptop mic','dim')}
46 <div style="height:var(--size-icon)">${line(bad?'frayed':'voice',live,voiceColor)}</div>${row('Noise suppression',toggle(true))}</div>`;47 <div style="height:var(--size-icon)">${line(bad?'frayed':'voice',live,voiceColor)}</div>${row('Noise suppression',toggle(true))}</div>`;
47-mount(document.getElementById('page'),`<div class="col" style="flex:1;gap:var(--space-xl)">${lines}${rows}</div><div class="col" style="width:calc(var(--size-talk) + var(--size-control));gap:var(--space-xl)">${controls}${pop}</div><div class="grow"></div>`);48+const callPage=()=>{const many=state==='many',empty=state==='empty';
48-document.getElementById('states').innerHTML=STATES.map(s=>`<a href="#${s}" class="${s===state?'on':''}" onclick="setTimeout(()=>location.reload())">${s}</a>`).join('');49+ const nm=state==='long'?'alice with a name that keeps going past the edge':empty?'':'alice';
50+ const ctl=`<div class="band" style="gap:var(--space-xs);flex:none">${icon(bad?'micoff':'mic',bad?'danger':'')}${icon('head')}${icon('video',many?'on':'')}${chev(false)}${icon('screen',many?'on':'')}${chev(false)}${icon('off','danger')}</div>`;
51+ return `<div class="col" style="height:100%"><div class="grow"></div><div class="thread"></div><div class="band" style="gap:var(--space-lg);height:calc(var(--size-row) + var(--space-md));padding:0 var(--space-lg)">${w(nm,'medium')}<div style="flex:1;min-width:var(--size-control);height:var(--size-icon)">${line(bad?'frayed':'voice',empty?null:bands(1),bad?'bad':empty?'off':'h-amber')}</div>${w(empty?'–':bad?'212 ms':'24 ms','label-t '+(bad?'bad':'faint'))}${ctl}</div></div>`};
52+if(page==='call'){document.body.style.padding='0';document.getElementById('states').style.display='none';document.getElementById('page').style.display='block';mount(document.getElementById('page'),callPage())}
53+else mount(document.getElementById('page'),`<div class="col" style="flex:1;gap:var(--space-xl)">${lines}${rows}</div><div class="col" style="width:calc(var(--size-talk) + var(--size-control));gap:var(--space-xl)">${controls}${pop}</div><div class="grow"></div>`);
54+document.getElementById('states').innerHTML=STATES.map(s=>`<a href="#${page}:${s}" class="${s===state?'on':''}" onclick="setTimeout(()=>location.reload())">${s}</a>`).join('');
49 </script></body></html>55 </script></body></html>
crates/client/design/parts.jsmodified+1 -1
@@ -1,5 +1,5 @@
1 window.Yumush=(()=>{1 window.Yumush=(()=>{
2-const ICON={mic:'<path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><path d="M12 19v3"/>',camera:'<path d="M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"/><circle cx="12" cy="13" r="3"/>',off:'<path d="M10.68 13.31a16 16 0 0 0 3.41 2.6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7 2 2 0 0 1 1.72 2v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.42 19.42 0 0 1-3.33-2.67m-2.67-3.34a19.79 19.79 0 0 1-3.07-8.63A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91"/><path d="M22 2 2 22"/>',up:'<path d="m18 15-6-6-6 6"/>'};2+const ICON={mic:'<path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><path d="M12 19v3"/>',camera:'<path d="M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"/><circle cx="12" cy="13" r="3"/>',off:'<path d="M10.68 13.31a16 16 0 0 0 3.41 2.6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7 2 2 0 0 1 1.72 2v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.42 19.42 0 0 1-3.33-2.67m-2.67-3.34a19.79 19.79 0 0 1-3.07-8.63A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91"/><path d="M22 2 2 22"/>',up:'<path d="m18 15-6-6-6 6"/>',micoff:'<path d="M2 2l20 20"/><path d="M18.89 13.23A7.12 7.12 0 0 0 19 12v-2"/><path d="M5 10v2a7 7 0 0 0 12 5"/><path d="M15 9.34V5a3 3 0 0 0-5.68-1.33"/><path d="M9 9v3a3 3 0 0 0 5.12 2.12"/><path d="M12 19v3"/>',head:'<path d="M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3"/>',video:'<path d="m16 13 5.22 3.48a.5.5 0 0 0 .78-.42V7.87a.5.5 0 0 0-.75-.43L16 10.5"/><rect x="2" y="6" width="14" height="12" rx="2"/>',screen:'<path d="M13 3H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-3"/><path d="M8 21h8"/><path d="M12 17v4"/><path d="m17 8 5-5"/><path d="M17 3h5v5"/>'};
3 const bands=seed=>Array.from({length:24},(_,i)=>(Math.sin(i*.7+seed)*.5+.5)*.8);3 const bands=seed=>Array.from({length:24},(_,i)=>(Math.sin(i*.7+seed)*.5+.5)*.8);
4 const w=(text,cls='')=>`<div class="w ${cls}">${text}</div>`;4 const w=(text,cls='')=>`<div class="w ${cls}">${text}</div>`;
5 const icon=(k,cls='')=>`<div class="icon ${cls}"><svg viewBox="0 0 24 24">${ICON[k]}</svg></div>`;5 const icon=(k,cls='')=>`<div class="icon ${cls}"><svg viewBox="0 0 24 24">${ICON[k]}</svg></div>`;
crates/client/src/gui.rsmodified+1 -0
@@ -42,6 +42,7 @@ use crate::{
42 };42 };
43 43
44 mod auth;44 mod auth;
45+mod call_bar;
45 pub mod gallery;46 pub mod gallery;
46 mod parts;47 mod parts;
47 pub mod style;48 pub mod style;
crates/client/src/gui/call_bar.rsadded+103 -0
@@ -0,0 +1,103 @@
1+use std::{collections::VecDeque, rc::Rc};
2+
3+use gpui_kit::{
4+ AnyElement, App, Div, FontWeight, InteractiveElement, ParentElement,
5+ SharedString, StatefulInteractiveElement, Styled, Window, assets::IconName, div, px,
6+};
7+
8+use super::{
9+ Tooltip as _,
10+ parts::{Ink, Text, Tone, Voice, band, icon_button, thread, voice_line, words},
11+ style::{Tokens, size, space},
12+};
13+
14+pub type Action = Rc<dyn Fn(&mut Window, &mut App)>;
15+
16+pub struct CallBar {
17+ pub name: SharedString,
18+ pub bands: Option<VecDeque<f32>>,
19+ pub voice: Voice,
20+ pub ping: Option<f32>,
21+ pub muted: bool,
22+ pub deafened: bool,
23+ pub camera: bool,
24+ pub screen: bool,
25+}
26+
27+pub struct CallActions {
28+ pub mute: Action,
29+ pub deafen: Action,
30+ pub camera: Action,
31+ pub screen: Action,
32+ pub leave: Action,
33+ pub stats: Action,
34+ pub camera_more: AnyElement,
35+ pub screen_more: AnyElement,
36+}
37+
38+fn run(action: &Action) -> impl Fn(&mut Window, &mut App) + 'static {
39+ let action = action.clone();
40+ move |window, cx| action(window, cx)
41+}
42+
43+pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div {
44+ let tone = |on: bool| if on { Tone::On } else { Tone::Idle };
45+ let alarm = |on: bool| if on { Tone::Danger } else { Tone::Idle };
46+ let ping_ink = if bar.voice == Voice::Frayed { Ink::Bad } else { Ink::Faint };
47+ let ping = bar.ping.map_or_else(|| "–".to_string(), |ping| format!("{ping:.0} ms"));
48+ let stats = run(&actions.stats);
49+ let controls = band(space::XS)
50+ .flex_none()
51+ .child(icon_button(
52+ format!("bar_mute_{}", bar.muted),
53+ if bar.muted { IconName::MicOff } else { IconName::Mic },
54+ if bar.muted { "Unmute" } else { "Mute" },
55+ alarm(bar.muted),
56+ t,
57+ run(&actions.mute),
58+ ))
59+ .child(icon_button(
60+ format!("bar_deafen_{}", bar.deafened),
61+ if bar.deafened { IconName::HeadphoneOff } else { IconName::Headphones },
62+ if bar.deafened { "Undeafen" } else { "Deafen" },
63+ alarm(bar.deafened),
64+ t,
65+ run(&actions.deafen),
66+ ))
67+ .child(icon_button(
68+ format!("bar_camera_{}", bar.camera),
69+ IconName::Video,
70+ if bar.camera { "Turn off camera" } else { "Turn on camera" },
71+ tone(bar.camera),
72+ t,
73+ run(&actions.camera),
74+ ))
75+ .child(actions.camera_more)
76+ .child(icon_button(
77+ format!("bar_screen_{}", bar.screen),
78+ IconName::ScreenShare,
79+ if bar.screen { "Stop sharing" } else { "Share screen" },
80+ tone(bar.screen),
81+ t,
82+ run(&actions.screen),
83+ ))
84+ .child(actions.screen_more)
85+ .child(icon_button("bar_leave", IconName::PhoneOff, "Leave call", Tone::Danger, t, run(&actions.leave)));
86+ div().flex_none().child(thread(t)).child(
87+ band(space::LG)
88+ .h(px(size::ROW + space::MD))
89+ .px(px(space::LG))
90+ .child(words(bar.name, Text::Ui, Ink::Paper, t).font_weight(FontWeight::MEDIUM).flex_none())
91+ .child(div().flex_1().min_w(px(size::CONTROL)).h(px(size::ICON)).child(voice_line(bar.bands.as_ref(), bar.voice, t)))
92+ .child(
93+ div()
94+ .id("bar_ping")
95+ .tip("Connection stats")
96+ .cursor_pointer()
97+ .flex_none()
98+ .on_click(move |_, window, cx| stats(window, cx))
99+ .child(words(ping, Text::Label, ping_ink, t)),
100+ )
101+ .child(controls),
102+ )
103+}
crates/client/src/gui/chat.rsmodified+1 -0
@@ -1377,6 +1377,7 @@ impl Yumush {
1377 None => panel.child(empty_state(palette)),1377 None => panel.child(empty_state(palette)),
1378 },1378 },
1379 })1379 })
1380+ .children(self.dock(entity, palette, cx))
1380 }1381 }
1381 1382
1382 fn stats_side(&self, palette: Palette) -> Option<impl IntoElement> {1383 fn stats_side(&self, palette: Palette) -> Option<impl IntoElement> {
crates/client/src/gui/dock.rsmodified+65 -356
@@ -1,372 +1,81 @@
1-use std::time::Instant;1+use std::rc::Rc;
2 2
3-use common::{3+use common::share::Kind;
4- model::{Community, Id},4+use gpui_kit::{App, Entity, IntoElement};
5- share::Kind,
6-};
7-use gpui_kit::{
8- App, Div, Entity, FontWeight, Hsla, InteractiveElement, IntoElement, ParentElement, Stateful,
9- StatefulInteractiveElement, Styled, Window, assets::IconName, component::Icon, div, px,
10-};
11 5
12 use super::{6 use super::{
13- Palette, Tooltip as _, Yumush, chat::VoiceState, clickable, community_name, entity_action,7+ Palette, Yumush,
14- hoverable_with, share_view::kind_icon, text, voice_stats, wave, widget::icon_button,8+ call_bar::{self, CallActions, CallBar},
9+ chat::VoiceState,
10+ entity_action,
11+ parts::Voice,
12+ style::Tokens,
13+ voice_stats::{self, Quality},
15 };14 };
16 15
17-const PING_POINTS: usize = 12;
18-
19 impl Yumush {16 impl Yumush {
20- pub(super) fn dock(&self, entity: &Entity<Self>, palette: Palette) -> Option<impl IntoElement> {17+ pub(super) fn dock(
21- let community = self.chat.voice_room()?;
22- let VoiceState::In { since, .. } = &self.chat.voice_state else {
23- return None;
24- };
25- let (muted, deafened) = self.chat.voice_flags()?;
26- let me = self.user.as_ref()?.id;
27- let tone = voice_stats::quality(&self.chat.voice_samples)
28- .map_or(palette.ok, |quality| quality.color(palette));
29- let panel = div()
30- .bg(tone.opacity(0.08))
31- .border_1()
32- .border_color(tone.opacity(0.2))
33- .rounded(px(10.))
34- .p(px(8.))
35- .flex()
36- .flex_col()
37- .gap(px(6.))
38- .child(self.dock_header(entity, community, *since, tone, palette))
39- .child(self.dock_voice(entity, me, muted, deafened, palette))
40- .child(self.dock_devices(entity, me, palette));
41-
42- Some(panel)
43- }
44-
45- fn dock_header(
46 &self,18 &self,
47 entity: &Entity<Self>,19 entity: &Entity<Self>,
48- community: &Community,
49- since: Instant,
50- tone: Hsla,
51 palette: Palette,20 palette: Palette,
52- ) -> Div {21+ cx: &App,
53- let direct = community.kind.is_direct();22+ ) -> Option<impl IntoElement> {
54- let go_id = community.id;23+ let community = self.chat.voice_room()?;
55- let go = entity_action(entity, move |yumush, window, cx| {24+ let VoiceState::In { .. } = &self.chat.voice_state else {
56- yumush.go_to_community(go_id, direct, window, cx)25+ return None;
57- });
58-
59- let ping = self
60- .chat
61- .voice_samples
62- .back()
63- .map_or(0., |sample| sample.ping_ms);
64- let start = self.chat.voice_samples.len().saturating_sub(PING_POINTS);
65- let pings: Vec<f32> = self
66- .chat
67- .voice_samples
68- .iter()
69- .skip(start)
70- .map(|sample| sample.ping_ms)
71- .collect();
72- let peak = pings.iter().copied().fold(1., f32::max);
73- let bars = div()
74- .w(px(PING_POINTS as f32 * 3.))
75- .h(px(12.))
76- .child(wave::line_of(
77- pings.iter().map(|ping| ping / peak * 0.9).collect(),
78- PING_POINTS,
79- tone,
80- ));
81-
82- div()
83- .flex()
84- .items_center()
85- .gap(px(7.))
86- .child(
87- clickable("dock_go", palette, go)
88- .tip("Go to channel")
89- .min_w_0()
90- .truncate()
91- .text_size(text(12.))
92- .font_weight(FontWeight::SEMIBOLD)
93- .text_color(tone)
94- .child(community_name(community).to_string()),
95- )
96- .child(
97- div()
98- .text_size(text(11.))
99- .text_color(palette.muted)
100- .child(elapsed_text(since)),
101- )
102- .child(div().flex_1())
103- .child(
104- div()
105- .id("dock_ping")
106- .tip("Ping")
107- .flex_shrink_0()
108- .h(px(22.))
109- .px(px(7.))
110- .rounded(px(6.))
111- .bg(tone.opacity(0.12))
112- .flex()
113- .items_center()
114- .gap(px(6.))
115- .child(bars)
116- .child(
117- div()
118- .text_size(text(11.))
119- .text_color(tone)
120- .child(format!("{ping:.0} ms")),
121- ),
122- )
123- .child(
124- icon_button(
125- "dock_leave",
126- palette,
127- IconName::PhoneOff,
128- "Leave call",
129- entity_action(entity, |yumush, _, cx| {
130- yumush.end_voice(cx);
131- cx.notify();
132- }),
133- )
134- .bg(palette.danger.opacity(0.13))
135- .text_color(palette.danger)
136- .hover(|style| style.bg(palette.danger.opacity(0.22))),
137- )
138- }
139-
140- fn dock_voice(
141- &self,
142- entity: &Entity<Self>,
143- me: Id,
144- muted: bool,
145- deafened: bool,
146- palette: Palette,
147- ) -> Div {
148- let tone = if muted || deafened {
149- palette.danger
150- } else {
151- palette.ok
152- };
153- let deafen_entity = entity.clone();
154- let mic_action = entity_action(entity, |yumush, window, cx| yumush.toggle_mute(window, cx));
155- let ghost = self.hidden_in_voice();
156- let mic_icon = if muted {
157- IconName::MicOff
158- } else {
159- IconName::Mic
160- };
161- let mic_tip = match (muted, ghost) {
162- (true, true) => "Speak as ghost",
163- (true, false) => "Unmute",
164- (false, _) => "Mute",
165 };26 };
166- let deafen_icon = if deafened {27+ let (muted, deafened) = self.chat.voice_flags()?;
167- IconName::HeadphoneOff28+ let user = self.user.as_ref()?;
29+ let me = user.id;
30+ let t = Tokens::of(cx);
31+ let frayed = voice_stats::quality(&self.chat.voice_samples) == Some(Quality::Poor);
32+ let voice = if frayed {
33+ Voice::Frayed
34+ } else if !muted && self.chat.waves.speaking.contains(&me) {
35+ Voice::Live(t.person(me))
168 } else {36 } else {
169- IconName::Headphones37+ Voice::Quiet
170 };38 };
171- let (deafen_bg, deafen_tone, deafen_hover) = if deafened {39+ let bar = CallBar {
172- (40+ name: user.username.clone().into(),
173- palette.danger.opacity(0.13),41+ bands: self.chat.waves.voice(me).cloned(),
174- palette.danger,42+ voice,
175- palette.danger.opacity(0.22),43+ ping: self.chat.voice_samples.back().map(|sample| sample.ping_ms),
176- )44+ muted,
177- } else {45+ deafened,
178- (palette.hover, palette.text, palette.hover)46+ camera: self.network.share_source(Kind::Camera).is_some(),
47+ screen: self.network.share_source(Kind::Screen).is_some(),
179 };48 };
180-49+ let (go_id, direct) = (community.id, community.kind.is_direct());
181- let voice = div()50+ let actions = CallActions {
182- .flex_1()51+ mute: Rc::new(entity_action(entity, |yumush, window, cx| {
183- .flex()52+ yumush.toggle_mute(window, cx)
184- .justify_center()53+ })),
185- .child(wave::wave_slot(54+ deafen: Rc::new(entity_action(entity, |yumush, _, cx| {
186- self.chat.waves.voice(me),55+ yumush.toggle_deafen(cx)
187- 14.,56+ })),
188- self.chat.waves.tone(me, Some(me), tone),57+ camera: Rc::new(entity_action(entity, |yumush, window, cx| {
189- ));58+ yumush.toggle_camera(window, cx)
190- let group = hoverable_with(59+ })),
191- "dock_mic",60+ screen: Rc::new(entity_action(entity, |yumush, window, cx| {
192- div()61+ yumush.toggle_share(window, cx)
193- .flex_1()62+ })),
194- .h(px(30.))63+ leave: Rc::new(entity_action(entity, |yumush, _, cx| {
195- .px(px(8.))64+ yumush.end_voice(cx);
196- .rounded(px(7.))65+ cx.notify();
197- .bg(tone.opacity(0.12))66+ })),
198- .flex()67+ stats: Rc::new(entity_action(entity, move |yumush, window, cx| {
199- .items_center()68+ yumush.go_to_community(go_id, direct, window, cx);
200- .gap(px(4.)),69+ yumush.chat.stats_open = !yumush.chat.stats_open;
201- tone.opacity(0.2),70+ cx.notify();
202- )71+ })),
203- .tip(mic_tip)72+ camera_more: self
204- .on_click(move |_, window, cx| mic_action(window, cx))73+ .share_settings_button(entity, palette, Kind::Camera, cx)
205- .child(Icon::new(mic_icon).w(px(14.)).h(px(14.)).text_color(tone))74+ .into_any_element(),
206- .child(voice);75+ screen_more: self
207- let deafen = icon_button(76+ .share_settings_button(entity, palette, Kind::Screen, cx)
208- format!("dock_deafen_{deafened}"),77+ .into_any_element(),
209- palette,
210- deafen_icon,
211- if deafened { "Undeafen" } else { "Deafen" },
212- move |_, cx| deafen_entity.update(cx, |yumush, cx| yumush.toggle_deafen(cx)),
213- )
214- .w(px(34.))
215- .h(px(30.))
216- .rounded(px(7.))
217- .bg(deafen_bg)
218- .text_color(deafen_tone)
219- .hover(move |style| style.bg(deafen_hover));
220-
221- div()
222- .flex()
223- .items_center()
224- .gap(px(4.))
225- .child(group)
226- .child(deafen)
227- }
228-
229- fn dock_devices(&self, entity: &Entity<Self>, me: Id, palette: Palette) -> Div {
230- let (on, off): (Vec<Kind>, Vec<Kind>) = [Kind::Camera, Kind::Screen]
231- .into_iter()
232- .partition(|kind| self.is_on(*kind));
233- let mut rows: Vec<Div> = on
234- .into_iter()
235- .map(|kind| self.device_row(entity, me, kind, palette))
236- .collect();
237- if !off.is_empty() {
238- rows.push(
239- div()
240- .flex()
241- .items_center()
242- .gap(px(4.))
243- .children(off.into_iter().map(|kind| {
244- div()
245- .flex_1()
246- .flex()
247- .items_center()
248- .gap(px(2.))
249- .child(start_button(entity, kind, palette))
250- .child(self.share_settings_button(entity, palette, kind))
251- })),
252- );
253- }
254- div().flex().flex_col().gap(px(4.)).children(rows)
255- }
256-
257- fn device_row(&self, entity: &Entity<Self>, me: Id, kind: Kind, palette: Palette) -> Div {
258- let tone = tone(palette, kind);
259- let stop_tip = match kind {
260- Kind::Camera => "Turn off camera",
261- Kind::Screen => "Stop sharing",
262 };78 };
263- let mut row = div()79+ Some(call_bar::view(bar, actions, t))
264- .h(px(30.))
265- .rounded(px(7.))
266- .pl(px(8.))
267- .pr(px(2.))
268- .bg(tone.opacity(0.1))
269- .flex()
270- .items_center()
271- .gap(px(4.))
272- .child(
273- Icon::new(kind_icon(kind))
274- .w(px(14.))
275- .h(px(14.))
276- .text_color(tone),
277- )
278- .child(
279- div()
280- .text_size(text(11.5))
281- .text_color(tone)
282- .child(self.mode_text(kind)),
283- );
284- if let Some(history) = self.chat.waves.share(me).filter(|_| kind == Kind::Screen) {
285- row = row.child(
286- div()
287- .id("dock_audio")
288- .tip("Screen audio")
289- .h(px(20.))
290- .px(px(5.))
291- .rounded(px(5.))
292- .bg(tone.opacity(0.12))
293- .flex()
294- .items_center()
295- .gap(px(3.))
296- .child(
297- Icon::new(IconName::Volume2)
298- .w(px(12.))
299- .h(px(12.))
300- .text_color(tone),
301- )
302- .child(wave::mini_wave(history, 10., tone)),
303- );
304- }
305- row.child(div().flex_1())
306- .child(self.share_settings_button(entity, palette, kind))
307- .child(
308- icon_button(
309- format!("dock_stop_{kind:?}"),
310- palette,
311- IconName::X,
312- stop_tip,
313- toggle_action(entity, kind),
314- )
315- .text_color(palette.danger),
316- )
317- }
318-
319- fn mode_text(&self, kind: Kind) -> String {
320- let top = self
321- .network
322- .share_source(kind)
323- .map_or_else(|| self.settings.share.top(kind), |source| source.top);
324- format!("{}p{}", top.resolution.height(), top.fps.value())
325- }
326-
327- fn is_on(&self, kind: Kind) -> bool {
328- self.network.share_source(kind).is_some()
329- }
330-}
331-
332-fn start_button(entity: &Entity<Yumush>, kind: Kind, palette: Palette) -> Stateful<Div> {
333- icon_button(
334- format!("dock_start_{kind:?}"),
335- palette,
336- kind_icon(kind),
337- match kind {
338- Kind::Camera => "Turn on camera",
339- Kind::Screen => "Share screen",
340- },
341- toggle_action(entity, kind),
342- )
343- .flex_1()
344- .h(px(30.))
345- .rounded(px(7.))
346- .bg(palette.hover)
347- .hover(move |style| style.bg(tone(palette, kind).opacity(0.2)))
348-}
349-
350-fn tone(palette: Palette, kind: Kind) -> Hsla {
351- match kind {
352- Kind::Camera => palette.camera,
353- Kind::Screen => palette.screen,
354- }
355-}
356-
357-fn toggle_action(entity: &Entity<Yumush>, kind: Kind) -> impl Fn(&mut Window, &mut App) + 'static {
358- let entity = entity.clone();
359- move |window: &mut Window, cx: &mut App| match kind {
360- Kind::Camera => entity.update(cx, |yumush, cx| yumush.toggle_camera(window, cx)),
361- Kind::Screen => entity.update(cx, |yumush, cx| yumush.toggle_share(window, cx)),
362- }
363-}
364-
365-fn elapsed_text(since: Instant) -> String {
366- let seconds = since.elapsed().as_secs();
367- let (hours, minutes, seconds) = (seconds / 3600, seconds / 60 % 60, seconds % 60);
368- match hours {
369- 0 => format!("{minutes:02}:{seconds:02}"),
370- _ => format!("{hours}:{minutes:02}:{seconds:02}"),
371 }80 }
372 }81 }
crates/client/src/gui/gallery.rsmodified+47 -1
@@ -14,6 +14,8 @@ use super::{
14 style::{Theme, Tokens, size, space},14 style::{Theme, Tokens, size, space},
15 };15 };
16 use crate::settings::FontSize;16 use crate::settings::FontSize;
17+use super::call_bar::{self, CallActions, CallBar};
18+use std::rc::Rc;
17 19
18 #[derive(Debug, Clone, Copy, PartialEq, Eq)]20 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
19 pub enum State {21 pub enum State {
@@ -94,13 +96,15 @@ impl Render for Gallery {
94 let t = Tokens::of(cx);96 let t = Tokens::of(cx);
95 let page = match self.page.as_str() {97 let page = match self.page.as_str() {
96 "parts" => parts_page(self.state, t).into_any_element(),98 "parts" => parts_page(self.state, t).into_any_element(),
99+ "call" => call_page(self.state, t).into_any_element(),
97 other => words(format!("no gallery page {other}"), Text::Body, Ink::Bad, t).into_any_element(),100 other => words(format!("no gallery page {other}"), Text::Body, Ink::Bad, t).into_any_element(),
98 };101 };
99 div()102 div()
100 .size_full()103 .size_full()
104+ .flex()
105+ .flex_col()
101 .bg(t.ground())106 .bg(t.ground())
102 .text_color(t.paper())107 .text_color(t.paper())
103- .p(px(space::XXL))
104 .child(page)108 .child(page)
105 }109 }
106 }110 }
@@ -187,7 +191,49 @@ fn parts_page(state: State, t: Tokens) -> impl IntoElement {
187 band(space::XXL)191 band(space::XXL)
188 .items_start()192 .items_start()
189 .size_full()193 .size_full()
194+ .p(px(space::XXL))
190 .child(stack(space::XL).flex_1().child(lines).child(rows))195 .child(stack(space::XL).flex_1().child(lines).child(rows))
191 .child(stack(space::XL).w(px(size::TALK + size::CONTROL)).child(controls).child(pop))196 .child(stack(space::XL).w(px(size::TALK + size::CONTROL)).child(controls).child(pop))
192 .child(grow())197 .child(grow())
193 }198 }
199+
200+fn call_page(state: State, t: Tokens) -> impl IntoElement {
201+ let bad = state == State::Bad;
202+ let bar = CallBar {
203+ name: match state {
204+ State::Long => "alice with a name that keeps going past the edge".into(),
205+ State::Empty => "".into(),
206+ _ => "alice".into(),
207+ },
208+ bands: (state != State::Empty).then(|| bands(1.)),
209+ voice: match state {
210+ State::Bad => Voice::Frayed,
211+ State::Empty => Voice::Quiet,
212+ _ => Voice::Live(t.hue(Hue::Amber)),
213+ },
214+ ping: match state {
215+ State::Empty => None,
216+ State::Bad => Some(212.),
217+ _ => Some(24.),
218+ },
219+ muted: bad,
220+ deafened: false,
221+ camera: state == State::Many,
222+ screen: state == State::Many,
223+ };
224+ let none = || -> call_bar::Action { Rc::new(|_, _| {}) };
225+ let actions = CallActions {
226+ mute: none(),
227+ deafen: none(),
228+ camera: none(),
229+ screen: none(),
230+ leave: none(),
231+ stats: none(),
232+ camera_more: super::parts::chevron_face(false, t).into_any_element(),
233+ screen_more: super::parts::chevron_face(false, t).into_any_element(),
234+ };
235+ column()
236+ .size_full()
237+ .child(grow())
238+ .child(call_bar::view(bar, actions, t))
239+}
crates/client/src/gui/parts.rsmodified+14 -19
@@ -73,12 +73,6 @@ pub fn strong(content: impl Into<SharedString>, style: Text, t: Tokens) -> Div {
73 words(content, style, Ink::Paper, t).font_weight(FontWeight::SEMIBOLD)73 words(content, style, Ink::Paper, t).font_weight(FontWeight::SEMIBOLD)
74 }74 }
75 75
76-pub fn colored(content: impl Into<SharedString>, style: Text, color: Hsla, t: Tokens) -> Div {
77- words(content, style, Ink::Paper, t)
78- .font_weight(FontWeight::MEDIUM)
79- .text_color(color)
80-}
81-
82 pub fn thread(t: Tokens) -> Div {76 pub fn thread(t: Tokens) -> Div {
83 div().w_full().h(px(stroke::LINE)).flex_none().bg(t.thread())77 div().w_full().h(px(stroke::LINE)).flex_none().bg(t.thread())
84 }78 }
@@ -250,25 +244,30 @@ pub fn icon_button(
250 .child(Icon::new(icon).size(px(size::ICON)))244 .child(Icon::new(icon).size(px(size::ICON)))
251 }245 }
252 246
253-pub fn chevron(247+pub fn chevron_face(open: bool, t: Tokens) -> Div {
254- id: impl Into<ElementId>,
255- open: bool,
256- t: Tokens,
257- on_click: impl Fn(&mut Window, &mut App) + 'static,
258-) -> Stateful<Div> {
259 div()248 div()
260- .id(id)
261- .cursor_pointer()
262 .w(px(16.))249 .w(px(16.))
263 .h(px(size::CONTROL))250 .h(px(size::CONTROL))
264 .flex()251 .flex()
252+ .flex_none()
265 .items_center()253 .items_center()
266 .justify_center()254 .justify_center()
255+ .cursor_pointer()
267 .text_color(if open { t.paper() } else { t.faint() })256 .text_color(if open { t.paper() } else { t.faint() })
268- .on_click(move |_, window, cx| on_click(window, cx))
269 .child(Icon::new(IconName::ChevronUp).size(px(13.)))257 .child(Icon::new(IconName::ChevronUp).size(px(13.)))
270 }258 }
271 259
260+pub fn chevron(
261+ id: impl Into<ElementId>,
262+ open: bool,
263+ t: Tokens,
264+ on_click: impl Fn(&mut Window, &mut App) + 'static,
265+) -> Stateful<Div> {
266+ chevron_face(open, t)
267+ .id(id)
268+ .on_click(move |_, window, cx| on_click(window, cx))
269+}
270+
272 pub fn popover(t: Tokens) -> Div {271 pub fn popover(t: Tokens) -> Div {
273 column()272 column()
274 .bg(t.raise())273 .bg(t.raise())
@@ -366,7 +365,3 @@ fn sample(levels: &[f32], along: f32) -> f32 {
366 pub fn spark(values: Vec<f32>, slots: usize, color: Hsla) -> AnyElement {365 pub fn spark(values: Vec<f32>, slots: usize, color: Hsla) -> AnyElement {
367 super::wave::line_of(values, slots, color).into_any_element()366 super::wave::line_of(values, slots, color).into_any_element()
368 }367 }
369-
370-pub fn person(content: impl Into<SharedString>, hue: Hsla, t: Tokens) -> Div {
371- colored(content, Text::Ui, hue, t).font_weight(FontWeight::SEMIBOLD)
372-}
crates/client/src/gui/share_view.rsmodified+5 -13
@@ -466,6 +466,7 @@ impl Yumush {
466 entity: &Entity<Self>,466 entity: &Entity<Self>,
467 palette: Palette,467 palette: Palette,
468 kind: Kind,468 kind: Kind,
469+ cx: &App,
469 ) -> impl IntoElement {470 ) -> impl IntoElement {
470 let refresh = entity.clone();471 let refresh = entity.clone();
471 let settings = entity.clone();472 let settings = entity.clone();
@@ -483,10 +484,10 @@ impl Yumush {
483 };484 };
484 485
485 Popover::new(id)486 Popover::new(id)
486- .anchor(Anchor::BottomLeft)487+ .anchor(Anchor::BottomRight)
487 .appearance(false)488 .appearance(false)
488 .trigger(Trigger::new(489 .trigger(Trigger::new(
489- div()490+ super::parts::chevron_face(false, super::style::Tokens::of(cx))
490 .id(button)491 .id(button)
491 .on_mouse_down(MouseButton::Left, move |_, _, cx| {492 .on_mouse_down(MouseButton::Left, move |_, _, cx| {
492 refresh.update(cx, |yumush, cx| {493 refresh.update(cx, |yumush, cx| {
@@ -497,23 +498,14 @@ impl Yumush {
497 }498 }
498 });499 });
499 })500 })
500- .tip(tip)501+ .tip(tip),
501- .size(px(22.))
502- .flex()
503- .flex_shrink_0()
504- .items_center()
505- .justify_center()
506- .rounded(px(6.))
507- .text_color(palette.muted)
508- .hover(|style| style.bg(palette.hover).text_color(palette.text))
509- .child(Icon::new(IconName::ChevronDown).w(px(13.)).h(px(13.))),
510 ))502 ))
511 .content(move |_, _, cx| {503 .content(move |_, _, cx| {
512 let entity = settings.clone();504 let entity = settings.clone();
513 pop_in(505 pop_in(
514 "share_settings_card",506 "share_settings_card",
515 settings_card(&entity, entity.read(cx), palette),507 settings_card(&entity, entity.read(cx), palette),
516- Anchor::BottomLeft,508+ Anchor::BottomRight,
517 )509 )
518 })510 })
519 }511 }
crates/client/src/gui/sidebar.rsmodified+0 -1
@@ -135,7 +135,6 @@ impl Yumush {
135 .overflow_y_scroll()135 .overflow_y_scroll()
136 .child(list),136 .child(list),
137 )137 )
138- .children(self.dock(entity, palette))
139 .children(self.account_row(entity, palette))138 .children(self.account_row(entity, palette))
140 .into_any_element()139 .into_any_element()
141 }140 }
crates/client/src/gui/style.rsmodified+1 -2
@@ -125,7 +125,7 @@ mod tests {
125 assert_eq!(names, HUE_NAMES);125 assert_eq!(names, HUE_NAMES);
126 }126 }
127 127
128- const UNMIGRATED: [&str; 37] = [128+ const UNMIGRATED: [&str; 36] = [
129 "gui.rs",129 "gui.rs",
130 "gui/auth.rs",130 "gui/auth.rs",
131 "gui/builder.rs",131 "gui/builder.rs",
@@ -145,7 +145,6 @@ mod tests {
145 "gui/chat.rs",145 "gui/chat.rs",
146 "gui/community_settings.rs",146 "gui/community_settings.rs",
147 "gui/composer.rs",147 "gui/composer.rs",
148- "gui/dock.rs",
149 "gui/forward.rs",148 "gui/forward.rs",
150 "gui/media_view.rs",149 "gui/media_view.rs",
151 "gui/message_actions.rs",150 "gui/message_actions.rs",
crates/client/src/gui/wave.rsmodified+0 -9
@@ -149,15 +149,6 @@ impl Waves {
149 }149 }
150 }150 }
151 151
152-pub fn wave_slot(history: Option<&VecDeque<f32>>, size: f32, color: Hsla) -> Div {
153- slot(
154- spectrum::BANDS,
155- history.map(|history| history.iter().copied().collect()),
156- size,
157- color,
158- )
159-}
160-
161 pub fn mini_wave(history: &VecDeque<f32>, size: f32, color: Hsla) -> Div {152 pub fn mini_wave(history: &VecDeque<f32>, size: f32, color: Hsla) -> Div {
162 let group = history.len().div_ceil(MINI_BARS).max(1);153 let group = history.len().div_ceil(MINI_BARS).max(1);
163 let bars: Vec<f32> = history154 let bars: Vec<f32> = history
harness/compare.shmodified+1 -1
@@ -8,7 +8,7 @@ out="$STATE/shots/gallery"
8 size=1120,7208 size=1120,720
9 [ "$state" = narrow ] && size=800,6009 [ "$state" = narrow ] && size=800,600
10 profile="$(mktemp -d -p "$STATE")"10 profile="$(mktemp -d -p "$STATE")"
11-firefox --headless --profile "$profile" --window-size "$size" --screenshot "$out/$page-$state-artifact.png" "file://$artifact#$state" >/dev/null 2>&111+firefox --headless --profile "$profile" --window-size "$size" --screenshot "$out/$page-$state-artifact.png" "file://$artifact#$page:$state" >/dev/null 2>&1
12 rm -rf "$profile"12 rm -rf "$profile"
13 magick montage "$out/$page-$state-artifact.png" "$out/$page-$state.png" -tile 2x1 -geometry +8+8 -background '#808080' "$out/$page-$state-compare.png"13 magick montage "$out/$page-$state-artifact.png" "$out/$page-$state.png" -tile 2x1 -geometry +8+8 -background '#808080' "$out/$page-$state-compare.png"
14 echo "$out/$page-$state-compare.png"14 echo "$out/$page-$state-compare.png"