forge
Explore
Log in

Don't you dare go Hollow

Aligned voice rows, strip/grid switch in header, viewer control bar, poll voters list

Browse files at this commit

f296e6e1cc4597474b04cb51ae0f108dae395366Ahmet Kaan GümüşParent: 05ce84c
  • style
    • aligned voice rows, strip/grid switch in header, viewer control bar, poll voters list
Show full message
💄 style: aligned voice rows, strip/grid switch in header, viewer control bar, poll voters list
crates/client/src/gui/camera_view.rsmodified+3 -37
@@ -11,7 +11,7 @@ use gpui_kit::{
1111 };
1212
1313 use super::{
14- Palette, Tooltip as _, Yumush, avatar, clickable, entity_action,
14+ Palette, Tooltip as _, Yumush, avatar, clickable,
1515 media_view::to_render_image,
1616 notify_error,
1717 share_view::{self, FRAME_TICK},
@@ -211,16 +211,7 @@ impl Yumush {
211211 .overflow_x_scroll()
212212 .border_b_1()
213213 .border_color(palette.border)
214- .children(tiles)
215- .child(icon_button(
216- "stage_grid",
217- palette,
218- IconName::LayoutDashboard,
219- "Grid",
220- entity_action(entity, |yumush, _, cx| {
221- yumush.set_stage(Stage::Grid, cx)
222- }),
223- )),
214+ .children(tiles),
224215 )
225216 }
226217
@@ -280,23 +271,7 @@ impl Yumush {
280271 .next()
281272 .unwrap_or_else(|| div().flex_1().into_any_element())
282273 }))
283- }))
284- .child(
285- icon_button(
286- "stage_minimize",
287- palette,
288- IconName::Minimize,
289- "Strip",
290- entity_action(entity, |yumush, _, cx| {
291- yumush.set_stage(Stage::Strip, cx)
292- }),
293- )
294- .absolute()
295- .top(px(12.))
296- .right(px(12.))
297- .bg(palette.panel)
298- .occlude(),
299- ),
274+ })),
300275 )
301276 }
302277 }
@@ -514,12 +489,3 @@ fn grid_cell(
514489 cell.into_any_element()
515490 }
516491 }
517-
518-pub(super) fn stage_toggle(yumush: &mut Yumush, cx: &mut Context<Yumush>) {
519- let next = if yumush.chat.stage == Stage::Hidden {
520- Stage::Strip
521- } else {
522- Stage::Hidden
523- };
524- yumush.set_stage(next, cx);
525-}
crates/client/src/gui/chat.rsmodified+58 -25
@@ -6,7 +6,7 @@ use std::{
66 time::{Duration, Instant},
77 };
88
9-use crate::gui::camera_view::{self, Stage, Tile};
9+use crate::gui::camera_view::{Stage, Tile};
1010 use crate::gui::social::InviteLookup;
1111 use crate::gui::voice_stats::{SAMPLE_HISTORY, StatsTab};
1212 use crate::gui::wave::Waves;
@@ -917,9 +917,15 @@ impl Chat {
917917 } else {
918918 self.messages
919919 .iter()
920+ .chain(&self.pins)
920921 .flat_map(|message| {
921922 std::iter::once(message.user_id)
922923 .chain(message.reply.as_ref().map(|quote| quote.user_id))
924+ .chain(message.poll.iter().flat_map(|poll| {
925+ poll.options
926+ .iter()
927+ .flat_map(|option| option.voter_ids.iter().copied())
928+ }))
923929 })
924930 .collect()
925931 };
@@ -2460,8 +2466,7 @@ impl Yumush {
24602466 if users.is_empty() {
24612467 return None;
24622468 }
2463- let stage = self.stage_sources().len();
2464- let hidden = self.chat.stage == Stage::Hidden;
2469+ let current = self.chat.stage;
24652470
24662471 Some(
24672472 div()
@@ -2488,32 +2493,33 @@ impl Yumush {
24882493 )
24892494 }))
24902495 .children(
2491- self.in_stage_chat()
2492- .then(|| {
2493- clickable(
2494- if hidden {
2495- "stage_toggle_hidden"
2496- } else {
2497- "stage_toggle_shown"
2498- },
2499- palette,
2500- entity_action(entity, |yumush: &mut Yumush, _, cx| {
2501- camera_view::stage_toggle(yumush, cx)
2502- }),
2503- )
2504- .tip(if hidden { "Show stage" } else { "Hide stage" })
2496+ self.in_stage_chat().then(|| {
2497+ div()
25052498 .ml(px(8.))
2506- .h(px(22.))
2507- .px(px(6.))
25082499 .flex()
25092500 .items_center()
2510- .gap(px(4.))
2501+ .p(px(2.))
2502+ .gap(px(2.))
25112503 .rounded(px(6.))
2512- .text_size(text(11.))
2513- .text_color(if hidden { palette.muted } else { palette.accent })
2514- .child(Icon::new(IconName::LayoutDashboard).w(px(14.)).h(px(14.)))
2515- .child(stage.to_string())
2516- }),
2504+ .border_1()
2505+ .border_color(palette.border)
2506+ .child(stage_button(
2507+ entity,
2508+ palette,
2509+ Stage::Strip,
2510+ current == Stage::Strip,
2511+ IconName::GalleryHorizontal,
2512+ "Strip",
2513+ ))
2514+ .child(stage_button(
2515+ entity,
2516+ palette,
2517+ Stage::Grid,
2518+ current == Stage::Grid,
2519+ IconName::LayoutGrid,
2520+ "Grid",
2521+ ))
2522+ }),
25172523 ),
25182524 )
25192525 }
@@ -3042,3 +3048,30 @@ fn hard_breaks(body: &str) -> String {
30423048 .collect();
30433049 lines.join("\n")
30443050 }
3051+
3052+fn stage_button(
3053+ entity: &Entity<Yumush>,
3054+ palette: Palette,
3055+ layout: Stage,
3056+ active: bool,
3057+ icon: IconName,
3058+ name: &'static str,
3059+) -> impl IntoElement {
3060+ clickable(
3061+ format!("stage_{name}_{active}"),
3062+ palette,
3063+ entity_action(entity, move |yumush: &mut Yumush, _, cx| {
3064+ let next = if active { Stage::Hidden } else { layout };
3065+ yumush.set_stage(next, cx)
3066+ }),
3067+ )
3068+ .tip(if active { "Hide" } else { name })
3069+ .size(px(22.))
3070+ .flex()
3071+ .items_center()
3072+ .justify_center()
3073+ .rounded(px(4.))
3074+ .when(active, |this| this.bg(palette.hover))
3075+ .text_color(if active { palette.accent } else { palette.muted })
3076+ .child(Icon::new(icon).w(px(14.)).h(px(14.)))
3077+}
crates/client/src/gui/poll.rsmodified+107 -13
@@ -2,15 +2,16 @@ use common::model::Id;
22 use common::call::{ClosePoll, MyVotes, Vote};
33 use common::model::{Message, Poll, Rank, User};
44 use gpui_kit::{
5- Context, Div, Entity, FontWeight, InteractiveElement, IntoElement, ParentElement, Styled,
6- Window, assets::IconName, component::Icon, div, prelude::FluentBuilder as _, px, relative,
5+ Anchor, AnyElement, Context, Div, Entity, FontWeight, InteractiveElement, IntoElement,
6+ ParentElement, StatefulInteractiveElement, Styled, Window, assets::IconName, component::Icon, component::popover::Popover,
7+ div, prelude::FluentBuilder as _, px, relative,
78 };
89
910 use super::{
10- Palette, Tooltip as _, Yumush, avatar,
11+ Palette, Trigger, Tooltip as _, Yumush, avatar,
1112 chat::Chat,
12- clickable, text,
13- widget::{icon_button, spawn_done},
13+ clickable, hoverable, pop_in, text,
14+ widget::{icon_button, panel, spawn_done},
1415 };
1516
1617 pub fn voter_count(poll: &Poll) -> usize {
@@ -57,6 +58,100 @@ fn status_icon(id: String, icon: IconName, tip: &'static str, palette: Palette)
5758 .child(Icon::new(icon).w(px(12.)).h(px(12.)))
5859 }
5960
61+fn voters_label(voters: usize) -> Div {
62+ div()
63+ .flex()
64+ .items_center()
65+ .gap(px(4.))
66+ .child(Icon::new(IconName::Users).w(px(12.)).h(px(12.)))
67+ .child(format!("{voters}"))
68+}
69+
70+fn voters_popover(key: &str, poll: &Poll, entity: &Entity<Yumush>, palette: Palette) -> AnyElement {
71+ let options = poll.options.clone();
72+ let list = format!("poll_voters_list_{key}");
73+ let open = entity.clone();
74+ Popover::new(format!("poll_voters_{key}"))
75+ .anchor(Anchor::BottomLeft)
76+ .appearance(false)
77+ .trigger(Trigger::new(hoverable(
78+ format!("poll_voters_trigger_{key}"),
79+ voters_label(voter_count(poll)),
80+ palette,
81+ )))
82+ .content(move |_, _, cx| {
83+ let yumush = open.read(cx);
84+ let chat = &yumush.chat;
85+ let rows = options
86+ .iter()
87+ .filter(|option| !option.voter_ids.is_empty())
88+ .map(|option| {
89+ div()
90+ .flex()
91+ .flex_col()
92+ .child(
93+ div()
94+ .h(px(26.))
95+ .flex()
96+ .items_center()
97+ .gap(px(8.))
98+ .text_size(text(11.))
99+ .text_color(palette.muted)
100+ .child(
101+ div()
102+ .flex_1()
103+ .min_w_0()
104+ .truncate()
105+ .child(option.text.clone()),
106+ )
107+ .child(
108+ div()
109+ .flex_shrink_0()
110+ .child(format!("{}", option.voter_ids.len())),
111+ ),
112+ )
113+ .children(option.voter_ids.iter().filter_map(|id| {
114+ chat.author(*id).map(|user| {
115+ div()
116+ .h(px(26.))
117+ .flex()
118+ .items_center()
119+ .gap(px(8.))
120+ .text_size(text(12.))
121+ .child(avatar(
122+ palette,
123+ user,
124+ px(18.),
125+ text(8.),
126+ &chat.avatars,
127+ ))
128+ .child(
129+ div()
130+ .flex_1()
131+ .min_w_0()
132+ .truncate()
133+ .child(user.username.clone()),
134+ )
135+ })
136+ }))
137+ });
138+ pop_in(
139+ list.clone(),
140+ panel(palette)
141+ .w(px(260.))
142+ .id(list.clone())
143+ .max_h(px(320.))
144+ .overflow_y_scroll()
145+ .p(px(6.))
146+ .flex()
147+ .flex_col()
148+ .children(rows),
149+ Anchor::BottomLeft,
150+ )
151+ })
152+ .into_any_element()
153+}
154+
60155 pub fn poll_card(
61156 poll: &Poll,
62157 mode: PollMode,
@@ -194,20 +289,19 @@ pub fn poll_card(
194289 )
195290 });
196291
292+ let voters_view = if poll.public {
293+ voters_popover(&key, poll, entity, palette)
294+ } else {
295+ voters_label(voters).into_any_element()
296+ };
297+
197298 let footer = div()
198299 .flex()
199300 .items_center()
200301 .justify_between()
201302 .text_size(text(12.))
202303 .text_color(palette.muted)
203- .child(
204- div()
205- .flex()
206- .items_center()
207- .gap(px(4.))
208- .child(Icon::new(IconName::Users).w(px(12.)).h(px(12.)))
209- .child(format!("{voters}")),
210- )
304+ .child(voters_view)
211305 .children(close_id.map(|close_id| {
212306 let close_entity = entity.clone();
213307 icon_button(
crates/client/src/gui/share_view.rsmodified+20 -37
@@ -24,7 +24,6 @@ use super::{
2424 notify_error, pop_in,
2525 settings_page::segmented,
2626 text,
27- wave::wave_slot,
2827 widget::{icon_button, spawn_warn},
2928 };
3029 use crate::{
@@ -452,6 +451,7 @@ impl Yumush {
452451 .relative()
453452 .occlude()
454453 .bg(gpui_kit::black())
454+ .group("viewer")
455455 .children(
456456 viewer
457457 .frame
@@ -461,53 +461,36 @@ impl Yumush {
461461 .child(
462462 div()
463463 .absolute()
464- .left(px(10.))
465- .top(px(10.))
466- .px(px(8.))
467- .py(px(4.))
468- .flex()
469- .items_center()
470- .gap(px(6.))
471- .rounded(px(6.))
472- .border_1()
473- .border_color(palette.border)
474- .bg(palette.panel)
475- .occlude()
476- .text_size(text(12.))
477- .child(Icon::new(kind_icon(viewer.kind)).w(px(14.)).h(px(14.)))
478- .child(name.to_string()),
479- )
480- .child(
481- div()
482- .absolute()
483- .right(px(10.))
484- .bottom(px(10.))
485- .p(px(6.))
464+ .left_0()
465+ .right_0()
466+ .bottom_0()
467+ .h(px(44.))
468+ .px(px(12.))
486469 .flex()
487470 .items_center()
488471 .gap(px(8.))
489- .rounded(px(8.))
490- .border_1()
491- .border_color(palette.border)
492- .bg(palette.panel)
472+ .bg(gpui_kit::black().opacity(0.55))
493473 .occlude()
474+ .opacity(0.)
475+ .group_hover("viewer", |style| style.opacity(1.))
494476 .text_size(text(12.))
495- .children(audio.then(|| {
496- wave_slot(self.chat.waves.share(viewer.user_id), 14., palette.alert)
497- }))
477+ .text_color(palette.text)
478+ .child(Icon::new(kind_icon(viewer.kind)).w(px(14.)).h(px(14.)))
479+ .child(name.to_string())
480+ .child(div().flex_1())
498481 .children(audio.then(|| {
499482 Icon::new(IconName::Volume2)
500483 .w(px(14.))
501484 .h(px(14.))
502485 .text_color(palette.muted)
503486 }))
504- .children(
505- audio.then(|| {
506- div()
507- .w(px(100.))
508- .child(Slider::new(&viewer.volume).bg(palette.muted))
509- }),
510- )
487+ .children(audio.then(|| {
488+ div().w(px(80.)).child(
489+ Slider::new(&viewer.volume)
490+ .bg(palette.accent)
491+ .text_color(palette.text),
492+ )
493+ }))
511494 .child(icon_button(
512495 format!("share_fullscreen_{}", viewer.fullscreen),
513496 palette,
crates/client/src/gui/sidebar.rsmodified+73 -42
@@ -240,8 +240,13 @@ impl Yumush {
240240 let screen = self.chat.share_of(community_id, user.id, Kind::Screen).is_some();
241241 let camera = self.chat.share_of(community_id, user.id, Kind::Camera).is_some();
242242
243+ let user_id = user.id;
244+ let watch_screen = entity.clone();
245+ let watch_camera = entity.clone();
246+ let sharing = self.chat.waves.share(user_id).is_some();
247+
243248 let member = profile_popover(
244- format!("voice_member_{}", user.id),
249+ format!("voice_member_{user_id}"),
245250 Anchor::BottomLeft,
246251 user,
247252 entity,
@@ -249,11 +254,9 @@ impl Yumush {
249254 .flex()
250255 .items_center()
251256 .gap(px(6.))
252- .px(px(4.))
253- .py(px(2.))
254- .rounded(px(6.))
257+ .flex_1()
258+ .min_w_0()
255259 .cursor_pointer()
256- .hover(move |style| style.bg(palette.hover))
257260 .child(
258261 avatar(palette, user, px(18.), text(9.), &self.chat.avatars)
259262 .border_2()
@@ -271,45 +274,73 @@ impl Yumush {
271274 .text_size(text(12.))
272275 .text_color(palette.text)
273276 .child(user.username.clone()),
274- )
275- .when(camera, |row| {
276- row.child(
277- Icon::new(IconName::Video)
278- .w(px(12.))
279- .h(px(12.))
280- .text_color(palette.alert),
281- )
282- })
283- .child(wave_slot(self.chat.waves.voice(user.id), 12., palette.ok)),
277+ ),
284278 );
285- let user_id = user.id;
286- let watch = entity.clone();
287-
288- div().flex().flex_col().child(member).when(screen, |column| {
289- column.child(
290- clickable(format!("voice_screen_{user_id}"), palette, move |window, cx| {
291- watch.update(cx, |yumush, cx| {
292- yumush.toggle_viewer(user_id, Kind::Screen, window, cx)
293- });
294- })
295- .tip("Watch")
296- .ml(px(28.))
297- .px(px(4.))
298- .py(px(2.))
299- .flex()
300- .items_center()
301- .gap(px(6.))
302- .rounded(px(6.))
303- .child(
304- Icon::new(IconName::ScreenShare)
305- .w(px(12.))
306- .h(px(12.))
307- .text_color(palette.alert),
308- )
309- .child(div().flex_1())
310- .child(wave_slot(self.chat.waves.share(user_id), 12., palette.alert)),
279+
280+ div()
281+ .flex()
282+ .items_center()
283+ .gap(px(4.))
284+ .px(px(4.))
285+ .py(px(2.))
286+ .rounded(px(6.))
287+ .hover(move |style| style.bg(palette.hover))
288+ .child(div().flex_1().min_w_0().child(member))
289+ .child(
290+ div()
291+ .w(px(20.))
292+ .h(px(20.))
293+ .flex_shrink_0()
294+ .when(screen, |slot| {
295+ slot.child(
296+ clickable(format!("voice_screen_{user_id}"), palette, move |window, cx| {
297+ watch_screen.update(cx, |yumush, cx| {
298+ yumush.toggle_viewer(user_id, Kind::Screen, window, cx)
299+ });
300+ })
301+ .tip("Watch")
302+ .size_full()
303+ .flex()
304+ .items_center()
305+ .justify_center()
306+ .rounded(px(4.))
307+ .child(
308+ Icon::new(IconName::ScreenShare)
309+ .w(px(12.))
310+ .h(px(12.))
311+ .text_color(if sharing { palette.ok } else { palette.alert }),
312+ ),
313+ )
314+ }),
311315 )
312- })
316+ .child(
317+ div()
318+ .w(px(20.))
319+ .h(px(20.))
320+ .flex_shrink_0()
321+ .when(camera, |slot| {
322+ slot.child(
323+ clickable(format!("voice_camera_{user_id}"), palette, move |window, cx| {
324+ watch_camera.update(cx, |yumush, cx| {
325+ yumush.toggle_viewer(user_id, Kind::Camera, window, cx)
326+ });
327+ })
328+ .tip("Watch")
329+ .size_full()
330+ .flex()
331+ .items_center()
332+ .justify_center()
333+ .rounded(px(4.))
334+ .child(
335+ Icon::new(IconName::Video)
336+ .w(px(12.))
337+ .h(px(12.))
338+ .text_color(palette.alert),
339+ ),
340+ )
341+ }),
342+ )
343+ .child(wave_slot(self.chat.waves.voice(user_id), 12., palette.ok))
313344 }
314345
315346 fn voice_dot(&self, entity: &Entity<Self>, palette: Palette) -> Option<impl IntoElement> {