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::{
11 };11 };
12 12
13 use super::{13 use super::{
14- Palette, Tooltip as _, Yumush, avatar, clickable, entity_action,14+ Palette, Tooltip as _, Yumush, avatar, clickable,
15 media_view::to_render_image,15 media_view::to_render_image,
16 notify_error,16 notify_error,
17 share_view::{self, FRAME_TICK},17 share_view::{self, FRAME_TICK},
@@ -211,16 +211,7 @@ impl Yumush {
211 .overflow_x_scroll()211 .overflow_x_scroll()
212 .border_b_1()212 .border_b_1()
213 .border_color(palette.border)213 .border_color(palette.border)
214- .children(tiles)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- )),
224 )215 )
225 }216 }
226 217
@@ -280,23 +271,7 @@ impl Yumush {
280 .next()271 .next()
281 .unwrap_or_else(|| div().flex_1().into_any_element())272 .unwrap_or_else(|| div().flex_1().into_any_element())
282 }))273 }))
283- }))274+ })),
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- ),
300 )275 )
301 }276 }
302 }277 }
@@ -514,12 +489,3 @@ fn grid_cell(
514 cell.into_any_element()489 cell.into_any_element()
515 }490 }
516 }491 }
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::{
6 time::{Duration, Instant},6 time::{Duration, Instant},
7 };7 };
8 8
9-use crate::gui::camera_view::{self, Stage, Tile};9+use crate::gui::camera_view::{Stage, Tile};
10 use crate::gui::social::InviteLookup;10 use crate::gui::social::InviteLookup;
11 use crate::gui::voice_stats::{SAMPLE_HISTORY, StatsTab};11 use crate::gui::voice_stats::{SAMPLE_HISTORY, StatsTab};
12 use crate::gui::wave::Waves;12 use crate::gui::wave::Waves;
@@ -917,9 +917,15 @@ impl Chat {
917 } else {917 } else {
918 self.messages918 self.messages
919 .iter()919 .iter()
920+ .chain(&self.pins)
920 .flat_map(|message| {921 .flat_map(|message| {
921 std::iter::once(message.user_id)922 std::iter::once(message.user_id)
922 .chain(message.reply.as_ref().map(|quote| quote.user_id))923 .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+ }))
923 })929 })
924 .collect()930 .collect()
925 };931 };
@@ -2460,8 +2466,7 @@ impl Yumush {
2460 if users.is_empty() {2466 if users.is_empty() {
2461 return None;2467 return None;
2462 }2468 }
2463- let stage = self.stage_sources().len();2469+ let current = self.chat.stage;
2464- let hidden = self.chat.stage == Stage::Hidden;
2465 2470
2466 Some(2471 Some(
2467 div()2472 div()
@@ -2488,32 +2493,33 @@ impl Yumush {
2488 )2493 )
2489 }))2494 }))
2490 .children(2495 .children(
2491- self.in_stage_chat()2496+ self.in_stage_chat().then(|| {
2492- .then(|| {2497+ div()
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" })
2505 .ml(px(8.))2498 .ml(px(8.))
2506- .h(px(22.))
2507- .px(px(6.))
2508 .flex()2499 .flex()
2509 .items_center()2500 .items_center()
2510- .gap(px(4.))2501+ .p(px(2.))
2502+ .gap(px(2.))
2511 .rounded(px(6.))2503 .rounded(px(6.))
2512- .text_size(text(11.))2504+ .border_1()
2513- .text_color(if hidden { palette.muted } else { palette.accent })2505+ .border_color(palette.border)
2514- .child(Icon::new(IconName::LayoutDashboard).w(px(14.)).h(px(14.)))2506+ .child(stage_button(
2515- .child(stage.to_string())2507+ entity,
2516- }),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+ }),
2517 ),2523 ),
2518 )2524 )
2519 }2525 }
@@ -3042,3 +3048,30 @@ fn hard_breaks(body: &str) -> String {
3042 .collect();3048 .collect();
3043 lines.join("\n")3049 lines.join("\n")
3044 }3050 }
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;
2 use common::call::{ClosePoll, MyVotes, Vote};2 use common::call::{ClosePoll, MyVotes, Vote};
3 use common::model::{Message, Poll, Rank, User};3 use common::model::{Message, Poll, Rank, User};
4 use gpui_kit::{4 use gpui_kit::{
5- Context, Div, Entity, FontWeight, InteractiveElement, IntoElement, ParentElement, Styled,5+ Anchor, AnyElement, Context, Div, Entity, FontWeight, InteractiveElement, IntoElement,
6- Window, assets::IconName, component::Icon, div, prelude::FluentBuilder as _, px, relative,6+ ParentElement, StatefulInteractiveElement, Styled, Window, assets::IconName, component::Icon, component::popover::Popover,
7+ div, prelude::FluentBuilder as _, px, relative,
7 };8 };
8 9
9 use super::{10 use super::{
10- Palette, Tooltip as _, Yumush, avatar,11+ Palette, Trigger, Tooltip as _, Yumush, avatar,
11 chat::Chat,12 chat::Chat,
12- clickable, text,13+ clickable, hoverable, pop_in, text,
13- widget::{icon_button, spawn_done},14+ widget::{icon_button, panel, spawn_done},
14 };15 };
15 16
16 pub fn voter_count(poll: &Poll) -> usize {17 pub fn voter_count(poll: &Poll) -> usize {
@@ -57,6 +58,100 @@ fn status_icon(id: String, icon: IconName, tip: &'static str, palette: Palette)
57 .child(Icon::new(icon).w(px(12.)).h(px(12.)))58 .child(Icon::new(icon).w(px(12.)).h(px(12.)))
58 }59 }
59 60
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+
60 pub fn poll_card(155 pub fn poll_card(
61 poll: &Poll,156 poll: &Poll,
62 mode: PollMode,157 mode: PollMode,
@@ -194,20 +289,19 @@ pub fn poll_card(
194 )289 )
195 });290 });
196 291
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+
197 let footer = div()298 let footer = div()
198 .flex()299 .flex()
199 .items_center()300 .items_center()
200 .justify_between()301 .justify_between()
201 .text_size(text(12.))302 .text_size(text(12.))
202 .text_color(palette.muted)303 .text_color(palette.muted)
203- .child(304+ .child(voters_view)
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- )
211 .children(close_id.map(|close_id| {305 .children(close_id.map(|close_id| {
212 let close_entity = entity.clone();306 let close_entity = entity.clone();
213 icon_button(307 icon_button(
crates/client/src/gui/share_view.rsmodified+20 -37
@@ -24,7 +24,6 @@ use super::{
24 notify_error, pop_in,24 notify_error, pop_in,
25 settings_page::segmented,25 settings_page::segmented,
26 text,26 text,
27- wave::wave_slot,
28 widget::{icon_button, spawn_warn},27 widget::{icon_button, spawn_warn},
29 };28 };
30 use crate::{29 use crate::{
@@ -452,6 +451,7 @@ impl Yumush {
452 .relative()451 .relative()
453 .occlude()452 .occlude()
454 .bg(gpui_kit::black())453 .bg(gpui_kit::black())
454+ .group("viewer")
455 .children(455 .children(
456 viewer456 viewer
457 .frame457 .frame
@@ -461,53 +461,36 @@ impl Yumush {
461 .child(461 .child(
462 div()462 div()
463 .absolute()463 .absolute()
464- .left(px(10.))464+ .left_0()
465- .top(px(10.))465+ .right_0()
466- .px(px(8.))466+ .bottom_0()
467- .py(px(4.))467+ .h(px(44.))
468- .flex()468+ .px(px(12.))
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.))
486 .flex()469 .flex()
487 .items_center()470 .items_center()
488 .gap(px(8.))471 .gap(px(8.))
489- .rounded(px(8.))472+ .bg(gpui_kit::black().opacity(0.55))
490- .border_1()
491- .border_color(palette.border)
492- .bg(palette.panel)
493 .occlude()473 .occlude()
474+ .opacity(0.)
475+ .group_hover("viewer", |style| style.opacity(1.))
494 .text_size(text(12.))476 .text_size(text(12.))
495- .children(audio.then(|| {477+ .text_color(palette.text)
496- wave_slot(self.chat.waves.share(viewer.user_id), 14., palette.alert)478+ .child(Icon::new(kind_icon(viewer.kind)).w(px(14.)).h(px(14.)))
497- }))479+ .child(name.to_string())
480+ .child(div().flex_1())
498 .children(audio.then(|| {481 .children(audio.then(|| {
499 Icon::new(IconName::Volume2)482 Icon::new(IconName::Volume2)
500 .w(px(14.))483 .w(px(14.))
501 .h(px(14.))484 .h(px(14.))
502 .text_color(palette.muted)485 .text_color(palette.muted)
503 }))486 }))
504- .children(487+ .children(audio.then(|| {
505- audio.then(|| {488+ div().w(px(80.)).child(
506- div()489+ Slider::new(&viewer.volume)
507- .w(px(100.))490+ .bg(palette.accent)
508- .child(Slider::new(&viewer.volume).bg(palette.muted))491+ .text_color(palette.text),
509- }),492+ )
510- )493+ }))
511 .child(icon_button(494 .child(icon_button(
512 format!("share_fullscreen_{}", viewer.fullscreen),495 format!("share_fullscreen_{}", viewer.fullscreen),
513 palette,496 palette,
crates/client/src/gui/sidebar.rsmodified+73 -42
@@ -240,8 +240,13 @@ impl Yumush {
240 let screen = self.chat.share_of(community_id, user.id, Kind::Screen).is_some();240 let screen = self.chat.share_of(community_id, user.id, Kind::Screen).is_some();
241 let camera = self.chat.share_of(community_id, user.id, Kind::Camera).is_some();241 let camera = self.chat.share_of(community_id, user.id, Kind::Camera).is_some();
242 242
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+
243 let member = profile_popover(248 let member = profile_popover(
244- format!("voice_member_{}", user.id),249+ format!("voice_member_{user_id}"),
245 Anchor::BottomLeft,250 Anchor::BottomLeft,
246 user,251 user,
247 entity,252 entity,
@@ -249,11 +254,9 @@ impl Yumush {
249 .flex()254 .flex()
250 .items_center()255 .items_center()
251 .gap(px(6.))256 .gap(px(6.))
252- .px(px(4.))257+ .flex_1()
253- .py(px(2.))258+ .min_w_0()
254- .rounded(px(6.))
255 .cursor_pointer()259 .cursor_pointer()
256- .hover(move |style| style.bg(palette.hover))
257 .child(260 .child(
258 avatar(palette, user, px(18.), text(9.), &self.chat.avatars)261 avatar(palette, user, px(18.), text(9.), &self.chat.avatars)
259 .border_2()262 .border_2()
@@ -271,45 +274,73 @@ impl Yumush {
271 .text_size(text(12.))274 .text_size(text(12.))
272 .text_color(palette.text)275 .text_color(palette.text)
273 .child(user.username.clone()),276 .child(user.username.clone()),
274- )277+ ),
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)),
284 );278 );
285- let user_id = user.id;279+
286- let watch = entity.clone();280+ div()
287-281+ .flex()
288- div().flex().flex_col().child(member).when(screen, |column| {282+ .items_center()
289- column.child(283+ .gap(px(4.))
290- clickable(format!("voice_screen_{user_id}"), palette, move |window, cx| {284+ .px(px(4.))
291- watch.update(cx, |yumush, cx| {285+ .py(px(2.))
292- yumush.toggle_viewer(user_id, Kind::Screen, window, cx)286+ .rounded(px(6.))
293- });287+ .hover(move |style| style.bg(palette.hover))
294- })288+ .child(div().flex_1().min_w_0().child(member))
295- .tip("Watch")289+ .child(
296- .ml(px(28.))290+ div()
297- .px(px(4.))291+ .w(px(20.))
298- .py(px(2.))292+ .h(px(20.))
299- .flex()293+ .flex_shrink_0()
300- .items_center()294+ .when(screen, |slot| {
301- .gap(px(6.))295+ slot.child(
302- .rounded(px(6.))296+ clickable(format!("voice_screen_{user_id}"), palette, move |window, cx| {
303- .child(297+ watch_screen.update(cx, |yumush, cx| {
304- Icon::new(IconName::ScreenShare)298+ yumush.toggle_viewer(user_id, Kind::Screen, window, cx)
305- .w(px(12.))299+ });
306- .h(px(12.))300+ })
307- .text_color(palette.alert),301+ .tip("Watch")
308- )302+ .size_full()
309- .child(div().flex_1())303+ .flex()
310- .child(wave_slot(self.chat.waves.share(user_id), 12., palette.alert)),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+ }),
311 )315 )
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))
313 }344 }
314 345
315 fn voice_dot(&self, entity: &Entity<Self>, palette: Palette) -> Option<impl IntoElement> {346 fn voice_dot(&self, entity: &Entity<Self>, palette: Palette) -> Option<impl IntoElement> {