forge
Explore
Log in

Don't you dare go Hollow

One voice line per person, louder meter, call events on the thread, builder list like chat, settings Profile/Camera & share/hue in Appearance, 15fps strip tiles

Browse files at this commit

1b03f20504a0917fc380f7c3a04da5ac6bdec034Ahmet Kaan GümüşParent: 2a068cb
  • feat
    • one voice line per person, louder meter, call events on the thread, builder list like chat, settings Profile/Camera & share/hue in Appearance, 15fps strip tiles
Show full message
✨ feat: one voice line per person, louder meter, call events on the thread, builder list like chat, settings Profile/Camera & share/hue in Appearance, 15fps strip tiles
crates/client/src/gui/builder/messages.rsmodified+70 -38
@@ -4,7 +4,8 @@ use common::{
44 model::MessageHit,
55 };
66 use gpui_kit::{
7- AnyElement, Context, Div, Entity, FontWeight, IntoElement, ParentElement, Styled, Window,
7+ AnyElement, Context, Div, Entity, FontWeight, InteractiveElement, IntoElement, ParentElement,
8+ Styled, Window,
89 assets::IconName,
910 component::{WindowExt, notification::Notification},
1011 div,
@@ -13,13 +14,12 @@ use gpui_kit::{
1314 };
1415
1516 use super::ui::{
16- accent_button, card, confirmed, delete_icon_button, end_of_day_ms, icon_button, list_card,
17- list_row, start_of_day_ms,
17+ accent_button, card, confirmed, delete_icon_button, end_of_day_ms, icon_button, start_of_day_ms,
1818 };
1919 use crate::gui::YEAR_STAMP;
20-use crate::gui::style::{size, space, text};
20+use crate::gui::style::{size, space, stroke, text};
2121 use crate::gui::{
22- Palette, Yumush, avatar,
22+ Palette, Yumush,
2323 community_settings::user_name,
2424 entity_action, millis_time, notify_error,
2525 profile::user_link,
@@ -31,12 +31,18 @@ fn message_hit_row(
3131 hit: &MessageHit,
3232 pending: bool,
3333 purge_pending: bool,
34- picture: Div,
3534 entity: &Entity<Yumush>,
3635 palette: Palette,
3736 ) -> Div {
3837 let message_id = hit.message.id;
3938 let community_id = hit.message.community_id;
39+ let group = format!("hit_{}", hit.message.id);
40+ let hue = hit
41+ .author
42+ .as_ref()
43+ .map_or(palette.tokens.faint(), |author| {
44+ palette.tokens.person(author.id)
45+ });
4046 let open = icon_button(
4147 format!("open_message_{}", hit.message.id),
4248 IconName::MessageSquare,
@@ -76,13 +82,26 @@ fn message_hit_row(
7682 })
7783 });
7884
79- list_row()
80- .child(user_link(
81- format!("hit_picture_{}", hit.message.id),
82- hit.author.as_ref(),
83- entity,
84- picture,
85- ))
85+ let dot = div()
86+ .absolute()
87+ .left(px(space::XL - space::SM / 2.0))
88+ .top(px(space::SM))
89+ .size(px(space::SM))
90+ .rounded_full()
91+ .bg(hue);
92+
93+ div()
94+ .group(group.clone())
95+ .relative()
96+ .flex()
97+ .items_start()
98+ .gap(px(space::MD))
99+ .min_w_0()
100+ .py(px(space::SM))
101+ .pl(px(space::XL + space::LG))
102+ .pr(px(space::LG))
103+ .hover(|style| style.bg(palette.hover))
104+ .child(dot)
86105 .child(
87106 div()
88107 .flex_1()
@@ -103,24 +122,24 @@ fn message_hit_row(
103122 div()
104123 .truncate()
105124 .text_size(text(text::LABEL))
106- .font_weight(FontWeight::MEDIUM)
107- .text_color(palette.text)
125+ .font_weight(FontWeight::SEMIBOLD)
126+ .text_color(hue)
108127 .child(user_name(&hit.author).to_string()),
109128 ))
110129 .child(
111130 div()
112- .min_w_0()
113- .truncate()
131+ .flex_shrink_0()
114132 .text_size(text(text::CAPTION))
115133 .text_color(palette.muted)
116- .child(hit.community.clone()),
134+ .child(millis_time(hit.message.created_at, YEAR_STAMP)),
117135 )
118136 .child(
119137 div()
120- .flex_shrink_0()
138+ .min_w_0()
139+ .truncate()
121140 .text_size(text(text::CAPTION))
122- .text_color(palette.muted)
123- .child(millis_time(hit.message.created_at, YEAR_STAMP)),
141+ .text_color(palette.tokens.faint())
142+ .child(hit.community.clone()),
124143 ),
125144 )
126145 .child(match hit.message.call {
@@ -128,7 +147,7 @@ fn message_hit_row(
128147 crate::gui::chat::call_line(call, user_name(&hit.author), false, palette)
129148 }
130149 None => div()
131- .text_size(text(text::LABEL))
150+ .text_size(text(text::BODY))
132151 .text_color(palette.body)
133152 .line_clamp(2)
134153 .child(hit.message.body.clone()),
@@ -136,10 +155,13 @@ fn message_hit_row(
136155 )
137156 .child(
138157 div()
158+ .id(format!("hit_actions_{}", hit.message.id))
139159 .flex()
140160 .items_center()
141161 .gap(px(space::XS))
142162 .flex_shrink_0()
163+ .invisible()
164+ .group_hover(group, |style| style.visible())
143165 .child(open)
144166 .child(delete)
145167 .children(purge),
@@ -201,27 +223,37 @@ impl Yumush {
201223 .author
202224 .as_ref()
203225 .is_some_and(|author| self.chat.pending_builder_purge == Some(author.id));
204- let picture = match &hit.author {
205- Some(author) => avatar(
206- palette,
207- author,
208- px(size::AVATAR),
209- text(text::CAPTION),
210- &self.chat.avatars,
211- ),
212- None => div()
213- .size(px(size::AVATAR))
214- .flex_shrink_0()
215- .rounded_full()
216- .bg(palette.hover),
217- };
218- message_hit_row(hit, pending, purge_pending, picture, entity, palette)
226+ message_hit_row(hit, pending, purge_pending, entity, palette)
219227 })
220228 .collect();
229+ let list = if rows.is_empty() {
230+ div()
231+ .py(px(space::XL))
232+ .flex()
233+ .justify_center()
234+ .text_size(text(text::CAPTION))
235+ .text_color(palette.muted)
236+ .child("No messages")
237+ } else {
238+ div()
239+ .relative()
240+ .flex()
241+ .flex_col()
242+ .child(
243+ div()
244+ .absolute()
245+ .left(px(space::XL))
246+ .top_0()
247+ .bottom_0()
248+ .w(px(stroke::LINE))
249+ .bg(palette.tokens.thread()),
250+ )
251+ .children(rows)
252+ };
221253
222254 vec![
223255 card(palette).child(filters).into_any_element(),
224- list_card(None, rows, "No messages", palette).into_any_element(),
256+ card(palette).child(list).into_any_element(),
225257 ]
226258 }
227259
crates/client/src/gui/camera_view.rsmodified+25 -39
@@ -6,7 +6,7 @@ use common::share::{Fps, Kind, Quality, Resolution};
66 use gpui_kit::{
77 AnyElement, AppContext as _, Context, Div, Entity, InteractiveElement, IntoElement,
88 ParentElement, StatefulInteractiveElement, Styled, Task, Window, assets::IconName,
9- component::Icon, div, px,
9+ component::Icon, div, prelude::FluentBuilder as _, px,
1010 };
1111
1212 use super::{
@@ -30,7 +30,7 @@ const TILE_H: f32 = TILE_W * 9. / 16.;
3030
3131 pub(super) const TILE_QUALITY: WatchQuality = WatchQuality::Fixed(Quality {
3232 resolution: Resolution::P360,
33- fps: Fps::F30,
33+ fps: Fps::F15,
3434 });
3535
3636 #[derive(Clone, Copy, PartialEq, Eq)]
@@ -254,7 +254,8 @@ impl Yumush {
254254 .voice_community()
255255 .map(|community_id| self.chat.voice_ids(community_id).to_vec())
256256 .unwrap_or_default();
257- self.voices_of(&ids, palette)
257+ let others: Vec<Id> = ids.into_iter().filter(|id| !self.is_me(*id)).collect();
258+ self.voices_of(&others, palette)
258259 }
259260
260261 fn slots(&self, ids: &[Id]) -> (Vec<Id>, usize) {
@@ -293,6 +294,7 @@ impl Yumush {
293294 voice_line(self.chat.waves.voice(user.id), voice, t),
294295 t,
295296 )
297+ .h(px(size::CONTROL_SM))
296298 })
297299 .chain(
298300 (more > 0)
@@ -359,7 +361,7 @@ impl Yumush {
359361 .chat
360362 .voice_ids(community_id)
361363 .iter()
362- .filter(|id| !sources.contains(&(**id, Kind::Camera)))
364+ .filter(|id| !sources.contains(&(**id, Kind::Camera)) && !self.is_me(**id))
363365 .copied()
364366 .collect();
365367 let columns = ((sources.len() as f32).sqrt().ceil() as usize).max(1);
@@ -489,19 +491,13 @@ fn stage_tile(
489491 .bg(t.raise())
490492 .children(surface),
491493 )
492- .child(caption(
494+ .child(tile_name(
493495 name,
494- voice_line(
495- yumush.chat.waves.voice(user_id),
496- if speaking {
497- Voice::Live(t.person(user_id))
498- } else if focused {
499- Voice::Live(t.paper())
500- } else {
501- Voice::Quiet
502- },
503- t,
504- ),
496+ if speaking || focused {
497+ Ink::Paper
498+ } else {
499+ Ink::Dim
500+ },
505501 t,
506502 ))
507503 }
@@ -580,17 +576,9 @@ fn grid_cell(
580576 .bg(t.raise())
581577 .children(surface),
582578 )
583- .child(caption(
579+ .child(tile_name(
584580 name,
585- voice_line(
586- yumush.chat.waves.voice(user_id),
587- if speaking {
588- Voice::Live(t.person(user_id))
589- } else {
590- Voice::Quiet
591- },
592- t,
593- ),
581+ if speaking { Ink::Paper } else { Ink::Dim },
594582 t,
595583 ))
596584 .into_any_element()
@@ -607,20 +595,10 @@ pub(super) fn tile_label(yumush: &Yumush, palette: Palette, (user_id, _): (Id, K
607595 || (yumush.is_me(user_id) && yumush.chat.voice_flags().is_some_and(|(muted, _)| muted));
608596
609597 scrim(t)
610- .child(words(name, Text::Label, Ink::Paper, t).flex_none())
611598 .child(
612- div()
613- .w(px(size::CONTROL))
614- .h(px(space::MD))
615- .child(voice_line(
616- yumush.chat.waves.voice(user_id),
617- if speaking {
618- Voice::Live(t.person(user_id))
619- } else {
620- Voice::Quiet
621- },
622- t,
623- )),
599+ words(name, Text::Label, Ink::Paper, t)
600+ .flex_none()
601+ .when(speaking, |name| name.text_color(t.person(user_id))),
624602 )
625603 .children(muted.then(|| {
626604 Icon::new(IconName::MicOff)
@@ -628,3 +606,11 @@ pub(super) fn tile_label(yumush: &Yumush, palette: Palette, (user_id, _): (Id, K
628606 .text_color(t.bad())
629607 }))
630608 }
609+
610+fn tile_name(name: impl Into<gpui_kit::SharedString>, ink: Ink, t: super::style::Tokens) -> Div {
611+ div()
612+ .h(px(size::ICON))
613+ .flex()
614+ .items_center()
615+ .child(words(name, Text::Label, ink, t))
616+}
crates/client/src/gui/chat.rsmodified+20 -4
@@ -1591,7 +1591,12 @@ impl Yumush {
15911591 .map(|(index, message)| {
15921592 let first = index == 0 || {
15931593 let previous = &self.chat.messages[index - 1];
1594- previous.user_id != message.user_id || previous.call.is_some()
1594+ match message.call {
1595+ Some(_) => previous.call.is_none(),
1596+ None => {
1597+ previous.user_id != message.user_id || previous.call.is_some()
1598+ }
1599+ }
15951600 };
15961601 let row = render_message(
15971602 message,
@@ -2869,6 +2874,7 @@ fn call_duration(seconds: u64) -> String {
28692874 fn render_call(
28702875 message: &Message,
28712876 call: CallLog,
2877+ spaced: bool,
28722878 chat: &Chat,
28732879 me: Option<&User>,
28742880 palette: Palette,
@@ -2879,6 +2885,8 @@ fn render_call(
28792885 .map_or("unknown", |user| user.username.as_str());
28802886 call_line(call, author, mine, palette)
28812887 .id(format!("message_row_{}", message.id))
2888+ .relative()
2889+ .when(spaced, |this| this.mt(px(space::LG)))
28822890 .into_any_element()
28832891 }
28842892
@@ -2897,12 +2905,20 @@ pub(super) fn call_line(call: CallLog, author: &str, mine: bool, palette: Palett
28972905 CallLog::Ended { seconds } => format!("Call ended · {}", call_duration(seconds)),
28982906 };
28992907 div()
2908+ .relative()
29002909 .flex()
29012910 .items_center()
2902- .gap(px(space::SM))
29032911 .text_size(text(text::CAPTION))
29042912 .text_color(palette.muted)
2905- .child(Icon::new(icon).size(px(size::ICON_SM)).text_color(color))
2913+ .child(
2914+ div()
2915+ .absolute()
2916+ .left(px(
2917+ -(space::LG + space::XS) - (size::ICON_SM - space::SM) / 2.
2918+ ))
2919+ .bg(palette.window)
2920+ .child(Icon::new(icon).size(px(size::ICON_SM)).text_color(color)),
2921+ )
29062922 .child(label)
29072923 }
29082924
@@ -2916,7 +2932,7 @@ fn render_message(
29162932 palette: Palette,
29172933 ) -> AnyElement {
29182934 if let Some(call) = message.call {
2919- return render_call(message, call, chat, me, palette);
2935+ return render_call(message, call, first && spaced, chat, me, palette);
29202936 }
29212937 let author = chat.author(message.user_id);
29222938 let username = author.map_or("unknown", |user| user.username.as_str());
crates/client/src/gui/parts.rsmodified+14 -3
@@ -363,6 +363,8 @@ pub enum Voice {
363363 Frayed,
364364 }
365365
366+const STILL: f32 = 0.02;
367+
366368 pub fn voice_line(bands: Option<&VecDeque<f32>>, voice: Voice, t: Tokens) -> AnyElement {
367369 let levels: Vec<f32> = bands
368370 .map(|bands| bands.iter().copied().collect())
@@ -373,6 +375,15 @@ pub fn voice_line(bands: Option<&VecDeque<f32>>, voice: Voice, t: Tokens) -> Any
373375 Voice::Frayed => t.bad(),
374376 };
375377 let frayed = voice == Voice::Frayed;
378+ let peak = levels.iter().copied().fold(0., f32::max);
379+ if peak < STILL && !frayed {
380+ return div()
381+ .size_full()
382+ .flex()
383+ .items_center()
384+ .child(div().w_full().h(px(stroke::LINE)).bg(color))
385+ .into_any_element();
386+ }
376387 canvas(
377388 |_, _, _| {},
378389 move |bounds, _, window, _| {
@@ -386,11 +397,11 @@ pub fn voice_line(bands: Option<&VecDeque<f32>>, voice: Voice, t: Tokens) -> Any
386397 }
387398 for step in 0..=steps {
388399 let along = step as f32 / steps as f32;
389- let level = sample(&levels, along);
390- let envelope = (std::f32::consts::PI * along).sin();
400+ let level = ((sample(&levels, along) + peak) / 2.).sqrt();
401+ let envelope = (std::f32::consts::PI * along).sin().sqrt();
391402 let swing = (step as f32 * 0.9).sin();
392403 let x = bounds.origin.x + bounds.size.width * along;
393- let y = middle + px(swing * level * envelope * half * 0.9);
404+ let y = middle + px(swing * level * envelope * half);
394405 if step == 0 {
395406 path.move_to(point(x, y));
396407 } else {
crates/client/src/gui/settings_page.rsmodified+263 -77
@@ -3,7 +3,8 @@ use std::future::Future;
33 use crate::net::Fail;
44 use common::{
55 call::{DeleteUser, RemoveAvatar, UpdateAvatar, UpdateHue, UpdateStatus, UpdateUser},
6- model::{Hue, User},
6+ model::{Hue, Presence, User},
7+ share::{self, Kind},
78 };
89 use gpui_kit::{
910 AnyElement, App, AsyncWindowContext, Context, Div, Entity, FontWeight, Hsla,
@@ -17,12 +18,18 @@ use gpui_kit::{
1718 };
1819
1920 use super::{
20- Palette, Tooltip as _, Yumush, avatar, chat::DeleteStep, chat::View, clickable, notify_error,
21- primary_button, text, widget::field,
21+ Palette, Tooltip as _, Yumush, avatar,
22+ chat::DeleteStep,
23+ chat::View,
24+ clickable, notify_error, parts, primary_button,
25+ share_view::{AudioMode, CODECS, FPS, RESOLUTIONS, share_modes},
26+ text,
27+ widget::field,
2228 };
2329 use crate::{
2430 gui::style::{self, Theme, radius, size, space, stroke, text},
25- settings::{self, FontSize},
31+ settings::{self, FontSize, ShareAudio, ShareCodec},
32+ share::encode::capabilities,
2633 };
2734
2835 impl Yumush {
@@ -34,6 +41,8 @@ impl Yumush {
3441 ) -> impl IntoElement {
3542 let mut sections = Vec::new();
3643 if let Some(user) = self.user.as_ref() {
44+ let presence_entity = entity.clone();
45+ let logout_entity = entity.clone();
3746 sections.push(Section(
3847 "Profile",
3948 div()
@@ -59,41 +68,74 @@ impl Yumush {
5968 entity,
6069 palette,
6170 ))
62- .child(row(
63- "Hue",
64- hue_picker(Some(style::hue_of(user.id)), entity, palette),
65- ))
66- .into_any_element(),
67- ));
68- sections.push(section(
69- "Account",
70- palette,
71- vec![
72- text_row(
73- Editable {
74- id: "save_username_button",
75- label: "Username",
76- input: &self.chat.username_input,
77- current: &user.username,
78- save: Yumush::save_username,
79- },
80- entity,
71+ .child(titled(
72+ "Identity",
8173 palette,
82- cx,
83- ),
84- text_row(
85- Editable {
86- id: "save_status_button",
87- label: "Status",
88- input: &self.chat.status_input,
89- current: &user.status,
90- save: Yumush::save_status,
91- },
92- entity,
74+ rows_column(
75+ palette,
76+ vec![
77+ text_row(
78+ Editable {
79+ id: "save_username_button",
80+ label: "Name",
81+ input: &self.chat.username_input,
82+ current: &user.username,
83+ save: Yumush::save_username,
84+ },
85+ entity,
86+ palette,
87+ cx,
88+ ),
89+ text_row(
90+ Editable {
91+ id: "save_status_button",
92+ label: "Status",
93+ input: &self.chat.status_input,
94+ current: &user.status,
95+ save: Yumush::save_status,
96+ },
97+ entity,
98+ palette,
99+ cx,
100+ ),
101+ row(
102+ "Presence",
103+ parts::options(
104+ "presence",
105+ Presence::ALL.map(|presence| (presence, presence.label())),
106+ self.presence_of(user.id),
107+ palette.tokens,
108+ move |presence, window, cx| {
109+ presence_entity.update(cx, |yumush, cx| {
110+ yumush.set_presence(presence, window, cx)
111+ })
112+ },
113+ ),
114+ ),
115+ ],
116+ ),
117+ ))
118+ .child(titled(
119+ "Account",
93120 palette,
94- cx,
95- ),
96- ],
121+ rows_column(
122+ palette,
123+ vec![row(
124+ "Log out",
125+ small_button(
126+ "logout_button",
127+ palette,
128+ palette.danger,
129+ move |window, cx| {
130+ logout_entity
131+ .update(cx, |yumush, cx| yumush.logout(window, cx))
132+ },
133+ )
134+ .child("Log out"),
135+ )],
136+ ),
137+ ))
138+ .into_any_element(),
97139 ));
98140 }
99141 sections.push(section(
@@ -101,49 +143,56 @@ impl Yumush {
101143 palette,
102144 self.voice_rows(entity, palette, cx),
103145 ));
104- sections.push(section(
105- "Appearance",
106- palette,
107- vec![
108- row(
109- "Theme",
110- segmented(
111- Theme::ALL.map(|choice| (choice, choice.label())),
112- self.settings.theme,
113- entity,
114- palette,
115- Yumush::set_theme,
116- ),
146+ sections.push(Section(
147+ "Camera & share",
148+ camera_share(self, entity, palette),
149+ ));
150+ let mut appearance = vec![
151+ row(
152+ "Theme",
153+ segmented(
154+ Theme::ALL.map(|choice| (choice, choice.label())),
155+ self.settings.theme,
156+ entity,
157+ palette,
158+ Yumush::set_theme,
117159 ),
118- row(
119- "Font size",
120- segmented(
121- FontSize::ALL.map(|size| (size, size.label())),
122- self.settings.font_size,
123- entity,
124- palette,
125- Yumush::set_font_size,
126- ),
160+ ),
161+ row(
162+ "Font size",
163+ segmented(
164+ FontSize::ALL.map(|size| (size, size.label())),
165+ self.settings.font_size,
166+ entity,
167+ palette,
168+ Yumush::set_font_size,
127169 ),
128- row(
129- "Close to tray",
130- super::parts::toggle(
131- "close_to_tray_switch",
132- self.settings.close_to_tray,
133- palette.tokens,
134- {
135- let entity = entity.clone();
136- move |_, cx| {
137- entity.update(cx, |yumush, cx| {
138- yumush.settings.close_to_tray = !yumush.settings.close_to_tray;
139- yumush.commit_settings(cx);
140- })
141- }
142- },
143- ),
170+ ),
171+ row(
172+ "Close to tray",
173+ super::parts::toggle(
174+ "close_to_tray_switch",
175+ self.settings.close_to_tray,
176+ palette.tokens,
177+ {
178+ let entity = entity.clone();
179+ move |_, cx| {
180+ entity.update(cx, |yumush, cx| {
181+ yumush.settings.close_to_tray = !yumush.settings.close_to_tray;
182+ yumush.commit_settings(cx);
183+ })
184+ }
185+ },
144186 ),
145- ],
146- ));
187+ ),
188+ ];
189+ if let Some(user) = self.user.as_ref() {
190+ appearance.push(row(
191+ "Your hue",
192+ hue_picker(Some(style::hue_of(user.id)), entity, palette),
193+ ));
194+ }
195+ sections.push(section("Appearance", palette, appearance));
147196 if self.user.is_some() {
148197 sections.push(danger_section(
149198 palette,
@@ -332,6 +381,135 @@ fn hue_picker(current: Option<Hue>, entity: &Entity<Yumush>, palette: Palette) -
332381 }))
333382 }
334383
384+fn camera_share(yumush: &Yumush, entity: &Entity<Yumush>, palette: Palette) -> AnyElement {
385+ div()
386+ .flex()
387+ .flex_col()
388+ .gap(px(space::XL))
389+ .child(titled(
390+ "Camera",
391+ palette,
392+ rows_column(palette, camera_rows(yumush, entity, palette)),
393+ ))
394+ .child(titled(
395+ "Screen share",
396+ palette,
397+ rows_column(palette, screen_rows(yumush, entity, palette)),
398+ ))
399+ .into_any_element()
400+}
401+
402+fn camera_rows(yumush: &Yumush, entity: &Entity<Yumush>, palette: Palette) -> Vec<Div> {
403+ let modes = share_modes(yumush, Kind::Camera);
404+ let max_height = capabilities().max_height;
405+ let top = share::clamp(yumush.settings.share.top(Kind::Camera), &modes, max_height);
406+ let (resolutions, fps) = share::options(&modes, top.resolution, max_height);
407+ vec![
408+ row(
409+ "Quality",
410+ parts::options(
411+ "camera_quality",
412+ RESOLUTIONS
413+ .into_iter()
414+ .filter(|(resolution, _)| resolutions.contains(resolution)),
415+ top.resolution,
416+ palette.tokens,
417+ share_pick(entity, Kind::Camera, Yumush::set_share_resolution),
418+ ),
419+ ),
420+ row(
421+ "Frame rate",
422+ parts::options(
423+ "camera_fps",
424+ FPS.into_iter().filter(|(value, _)| fps.contains(value)),
425+ top.fps,
426+ palette.tokens,
427+ share_pick(entity, Kind::Camera, Yumush::set_share_fps),
428+ ),
429+ ),
430+ ]
431+}
432+
433+fn screen_rows(yumush: &Yumush, entity: &Entity<Yumush>, palette: Palette) -> Vec<Div> {
434+ let settings = &yumush.settings.share;
435+ let modes = share_modes(yumush, Kind::Screen);
436+ let max_height = capabilities().max_height;
437+ let top = share::clamp(settings.top(Kind::Screen), &modes, max_height);
438+ let (resolutions, fps) = share::options(&modes, top.resolution, max_height);
439+ let audio_on = settings.audio != ShareAudio::Off;
440+ let audio_entity = entity.clone();
441+ vec![
442+ row(
443+ "Quality",
444+ parts::options(
445+ "screen_quality",
446+ RESOLUTIONS
447+ .into_iter()
448+ .filter(|(resolution, _)| resolutions.contains(resolution)),
449+ top.resolution,
450+ palette.tokens,
451+ share_pick(entity, Kind::Screen, Yumush::set_share_resolution),
452+ ),
453+ ),
454+ row(
455+ "Frame rate",
456+ parts::options(
457+ "screen_fps",
458+ FPS.into_iter().filter(|(value, _)| fps.contains(value)),
459+ top.fps,
460+ palette.tokens,
461+ share_pick(entity, Kind::Screen, Yumush::set_share_fps),
462+ ),
463+ ),
464+ row(
465+ "Codec",
466+ parts::options(
467+ "share_codec",
468+ CODECS.into_iter().filter(|(codec, _)| match codec {
469+ ShareCodec::Auto => true,
470+ ShareCodec::Only(codec) => capabilities().encode.contains(codec),
471+ }),
472+ settings.codec,
473+ palette.tokens,
474+ share_pick(entity, Kind::Screen, Yumush::set_share_codec),
475+ ),
476+ ),
477+ row(
478+ "Share audio",
479+ parts::toggle(
480+ "share_audio_switch",
481+ audio_on,
482+ palette.tokens,
483+ move |_, cx| {
484+ audio_entity.update(cx, |yumush, cx| {
485+ let mode = if audio_on {
486+ AudioMode::Off
487+ } else {
488+ AudioMode::Everything
489+ };
490+ yumush.set_share_audio_mode(mode, cx)
491+ })
492+ },
493+ ),
494+ ),
495+ ]
496+}
497+
498+fn share_pick<T: Copy + 'static>(
499+ entity: &Entity<Yumush>,
500+ kind: Kind,
501+ set: fn(&mut Yumush, T, &mut Context<Yumush>),
502+) -> impl Fn(T, &mut Window, &mut App) + Clone + 'static {
503+ let entity = entity.clone();
504+ move |value, _, cx| {
505+ entity.update(cx, |yumush, cx| {
506+ let tab = std::mem::replace(&mut yumush.share_tab, kind);
507+ set(yumush, value, cx);
508+ yumush.share_tab = tab;
509+ })
510+ }
511+}
512+
335513 pub(super) fn picked_avatar(
336514 cx: &App,
337515 maximum: u64,
@@ -469,6 +647,14 @@ pub(super) fn danger_section(palette: Palette, rows: Vec<Div>) -> Section {
469647 Section("Danger zone", rows_column(palette, rows))
470648 }
471649
650+fn titled(title: &'static str, palette: Palette, rows: impl IntoElement) -> Div {
651+ div()
652+ .flex()
653+ .flex_col()
654+ .child(parts::section(title, palette.tokens))
655+ .child(rows)
656+}
657+
472658 fn rows_column(palette: Palette, rows: Vec<Div>) -> AnyElement {
473659 div()
474660 .flex()
crates/client/src/gui/share_view.rsmodified+4 -4
@@ -56,7 +56,7 @@ const BAR_TTL: Duration = Duration::from_millis(2500);
5656 const APPS_REFRESH: Duration = Duration::from_secs(2);
5757 const APPS_IDLE: Duration = Duration::from_secs(5);
5858
59-const RESOLUTIONS: [(Resolution, &str); 6] = [
59+pub(super) const RESOLUTIONS: [(Resolution, &str); 6] = [
6060 (Resolution::P360, "360"),
6161 (Resolution::P480, "480"),
6262 (Resolution::P720, "720"),
@@ -64,9 +64,9 @@ const RESOLUTIONS: [(Resolution, &str); 6] = [
6464 (Resolution::P1440, "1440"),
6565 (Resolution::P2160, "2160"),
6666 ];
67-const FPS: [(Fps, &str); 3] = [(Fps::F15, "15"), (Fps::F30, "30"), (Fps::F60, "60")];
67+pub(super) const FPS: [(Fps, &str); 3] = [(Fps::F15, "15"), (Fps::F30, "30"), (Fps::F60, "60")];
6868
69-const CODECS: [(ShareCodec, &str); 4] = [
69+pub(super) const CODECS: [(ShareCodec, &str); 4] = [
7070 (ShareCodec::Auto, "Auto"),
7171 (ShareCodec::Only(Codec::Av1), "AV1"),
7272 (ShareCodec::Only(Codec::H265), "H265"),
@@ -795,7 +795,7 @@ fn settings_card(entity: &Entity<Yumush>, yumush: &Yumush, palette: Palette) ->
795795 })
796796 }
797797
798-fn share_modes(yumush: &Yumush, kind: Kind) -> Vec<Mode> {
798+pub(super) fn share_modes(yumush: &Yumush, kind: Kind) -> Vec<Mode> {
799799 yumush
800800 .network
801801 .share_modes(kind)
crates/client/src/gui/sidebar.rsmodified+15 -43
@@ -187,12 +187,14 @@ impl Yumush {
187187 .flex()
188188 .items_center()
189189 .gap(px(space::XS))
190- .child(
191- div()
192- .w(px(size::CONTROL))
193- .h(px(space::MD))
194- .child(super::parts::voice_line(wave, voice, palette.tokens)),
195- )
190+ .when(self.chat.voice_community() != Some(community_id), |this| {
191+ this.child(
192+ div()
193+ .w(px(size::CONTROL))
194+ .h(px(space::MD))
195+ .child(super::parts::voice_line(wave, voice, palette.tokens)),
196+ )
197+ })
196198 .child(
197199 div()
198200 .text_size(text(text::CAPTION))
@@ -242,11 +244,6 @@ impl Yumush {
242244 let speaking = self.chat.waves.speaking.contains(&user_id);
243245 let shown = speaking || (me && !muted);
244246 let wave = shown.then(|| self.chat.waves.voice(user_id)).flatten();
245- let voice = if wave.is_some() {
246- super::parts::Voice::Live(palette.tinted(user_id))
247- } else {
248- super::parts::Voice::Quiet
249- };
250247 let camera = self
251248 .chat
252249 .share_of(community_id, user_id, Kind::Camera)
@@ -277,13 +274,6 @@ impl Yumush {
277274 .when(speaking, |name| name.font_weight(FontWeight::SEMIBOLD))
278275 .child(user.username.clone()),
279276 )
280- .child(
281- div()
282- .w(px(size::CONTROL))
283- .h(px(space::MD))
284- .flex_none()
285- .child(super::parts::voice_line(wave, voice, palette.tokens)),
286- )
287277 .children((muted && wave.is_none()).then(|| {
288278 Icon::new(IconName::MicOff)
289279 .size(px(size::ICON_SM))
@@ -942,13 +932,6 @@ impl Yumush {
942932 named: bool,
943933 palette: Palette,
944934 ) -> impl IntoElement {
945- let speaking = self.chat.waves.speaking.contains(&user.id);
946- let own_wave = self.chat.waves.voice(user.id);
947- let own_voice = if speaking {
948- super::parts::Voice::Live(palette.tokens.person(user.id))
949- } else {
950- super::parts::Voice::Quiet
951- };
952935 profile_popover(
953936 "account_profile",
954937 Anchor::BottomLeft,
@@ -978,24 +961,13 @@ impl Yumush {
978961 ))
979962 })
980963 .when(named, |trigger| {
981- trigger
982- .child(
983- div()
984- .min_w_0()
985- .truncate()
986- .text_color(palette.muted)
987- .child(user.username.clone()),
988- )
989- .child(
990- div()
991- .w(px(size::CONTROL + space::LG))
992- .h(px(space::MD))
993- .child(super::parts::voice_line(
994- own_wave,
995- own_voice,
996- palette.tokens,
997- )),
998- )
964+ trigger.child(
965+ div()
966+ .min_w_0()
967+ .truncate()
968+ .text_color(palette.muted)
969+ .child(user.username.clone()),
970+ )
999971 }),
1000972 palette,
1001973 ),