BlueGit

ict rusty-teams

feat(calls): Fit to frame / Fill frame per video tile

- tile menu of a remote person with video: "Fit to frame" shows the whole picture (contain), "Fill frame" goes back to the cropped default
- per tile, per call, local only (nothing others see)
- deviation: in 1:1 calls the item shows even while the other camera is off (1:1 tiles carry no video flag)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-11-04 · 3 weeks ago

Hash
8eb89692436adb29372b658db4e9cdea41de0636
Parent
e7ea3d7f
4 files changed +55 −1
crates/app-call-model/src/model.rs +24 −0
@@ -1,4 +1,5 @@
1 1 use std::cell::Cell;
2 use std::collections::HashSet;
2 3 use std::rc::Rc;
3 4 use std::sync::Arc;
4 5 use std::time::{Duration, Instant};
@@ -302,6 +303,7 @@ pub struct CallModel {
302 303 pub own_role: Option<MeetingRole>,
303 304 pub capability: MeetingCapability,
304 305 pub pinned: Option<String>,
306 pub fitted: HashSet<String>,
305 307 pub captions: CaptionState,
306 308 pub caption_lines: Vec<CaptionLine>,
307 309 pub transcript: Transcript,
@@ -368,6 +370,7 @@ impl CallModel {
368 370 own_role: None,
369 371 capability: MeetingCapability::default(),
370 372 pinned: None,
373 fitted: HashSet::new(),
371 374 captions: CaptionState::Off,
372 375 caption_lines: Vec::new(),
373 376 transcript: Transcript::default(),
@@ -708,6 +711,16 @@ impl CallModel {
708 711 self.refresh_layout(Instant::now());
709 712 }
710 713
714 pub fn is_fitted(&self, mri: &str) -> bool {
715 self.fitted.contains(mri)
716 }
717
718 pub fn toggle_fit(&mut self, mri: &str) {
719 if !self.fitted.remove(mri) {
720 self.fitted.insert(mri.to_owned());
721 }
722 }
723
711 724 pub fn is_spotlighted(&self, mri: &str) -> bool {
712 725 self.own_mri.as_deref() == Some(mri) && self.own_spotlight.is_some()
713 726 || self
@@ -1563,6 +1576,17 @@ mod tests {
1563 1576 .collect()
1564 1577 }
1565 1578
1579 #[test]
1580 fn fit_to_frame_is_per_tile_and_toggles_back_to_fill() {
1581 let mut model = meeting_with_me();
1582 assert!(!model.is_fitted("8:orgid:a"));
1583 model.toggle_fit("8:orgid:a");
1584 assert!(model.is_fitted("8:orgid:a"));
1585 assert!(!model.is_fitted("8:orgid:b"));
1586 model.toggle_fit("8:orgid:a");
1587 assert!(!model.is_fitted("8:orgid:a"));
1588 }
1589
1566 1590 #[test]
1567 1591 fn hiding_people_without_video_keeps_speakers_and_the_pinned_person() {
1568 1592 let mut model = meeting_with_me();
@@ -1,4 +1,5 @@
1use std::cell::Cell;
1use std::cell::Cell;
2use std::collections::HashSet;
2use std::rc::Rc;
3use std::rc::Rc;
3use std::sync::Arc;
4use std::sync::Arc;
4use std::time::{Duration, Instant};
5use std::time::{Duration, Instant};
@@ -302,6 +303,7 @@ pub struct CallModel {
302 pub own_role: Option<MeetingRole>,
303 pub own_role: Option<MeetingRole>,
303 pub capability: MeetingCapability,
304 pub capability: MeetingCapability,
304 pub pinned: Option<String>,
305 pub pinned: Option<String>,
306 pub fitted: HashSet<String>,
305 pub captions: CaptionState,
307 pub captions: CaptionState,
306 pub caption_lines: Vec<CaptionLine>,
308 pub caption_lines: Vec<CaptionLine>,
307 pub transcript: Transcript,
309 pub transcript: Transcript,
@@ -368,6 +370,7 @@ impl CallModel {
368 own_role: None,
370 own_role: None,
369 capability: MeetingCapability::default(),
371 capability: MeetingCapability::default(),
370 pinned: None,
372 pinned: None,
373 fitted: HashSet::new(),
371 captions: CaptionState::Off,
374 captions: CaptionState::Off,
372 caption_lines: Vec::new(),
375 caption_lines: Vec::new(),
373 transcript: Transcript::default(),
376 transcript: Transcript::default(),
@@ -708,6 +711,16 @@ impl CallModel {
708 self.refresh_layout(Instant::now());
711 self.refresh_layout(Instant::now());
709 }
712 }
710
713
714 pub fn is_fitted(&self, mri: &str) -> bool {
715 self.fitted.contains(mri)
716 }
717
718 pub fn toggle_fit(&mut self, mri: &str) {
719 if !self.fitted.remove(mri) {
720 self.fitted.insert(mri.to_owned());
721 }
722 }
723
711 pub fn is_spotlighted(&self, mri: &str) -> bool {
724 pub fn is_spotlighted(&self, mri: &str) -> bool {
712 self.own_mri.as_deref() == Some(mri) && self.own_spotlight.is_some()
725 self.own_mri.as_deref() == Some(mri) && self.own_spotlight.is_some()
713 || self
726 || self
@@ -1563,6 +1576,17 @@ mod tests {
1563 .collect()
1576 .collect()
1564 }
1577 }
1565
1578
1579 #[test]
1580 fn fit_to_frame_is_per_tile_and_toggles_back_to_fill() {
1581 let mut model = meeting_with_me();
1582 assert!(!model.is_fitted("8:orgid:a"));
1583 model.toggle_fit("8:orgid:a");
1584 assert!(model.is_fitted("8:orgid:a"));
1585 assert!(!model.is_fitted("8:orgid:b"));
1586 model.toggle_fit("8:orgid:a");
1587 assert!(!model.is_fitted("8:orgid:a"));
1588 }
1589
1566 #[test]
1590 #[test]
1567 fn hiding_people_without_video_keeps_speakers_and_the_pinned_person() {
1591 fn hiding_people_without_video_keeps_speakers_and_the_pinned_person() {
1568 let mut model = meeting_with_me();
1592 let mut model = meeting_with_me();
crates/app-state/src/call/actions.rs +7 −0
@@ -897,6 +897,13 @@ impl AppState {
897 897 }
898 898 }
899 899
900 pub fn toggle_call_fit(&mut self, mri: &str, cx: &mut Context<Self>) {
901 if let Some(call) = self.call.as_mut() {
902 call.model.toggle_fit(mri);
903 cx.notify();
904 }
905 }
906
900 907 pub fn toggle_call_captions(&mut self, _cx: &mut Context<Self>) {
901 908 let Some(call) = self
902 909 .call
@@ -897,6 +897,13 @@ impl AppState {
897 }
897 }
898 }
898 }
899
899
900 pub fn toggle_call_fit(&mut self, mri: &str, cx: &mut Context<Self>) {
901 if let Some(call) = self.call.as_mut() {
902 call.model.toggle_fit(mri);
903 cx.notify();
904 }
905 }
906
900 pub fn toggle_call_captions(&mut self, _cx: &mut Context<Self>) {
907 pub fn toggle_call_captions(&mut self, _cx: &mut Context<Self>) {
901 let Some(call) = self
908 let Some(call) = self
902 .call
909 .call
crates/app/src/views/call_organizer.rs +16 −0
@@ -249,6 +249,22 @@ pub fn tile_menu(
249 249 pin_app.update(cx, |state, cx| state.toggle_call_pin(&pin_mri, cx))
250 250 }),
251 251 );
252 if model.is_one_to_one()
253 || model
254 .tiles
255 .iter()
256 .any(|tile| tile.mri == mri && tile.has_video)
257 {
258 let (fit_app, fit_mri) = (app.clone(), mri.to_owned());
259 let fitted = model.is_fitted(mri);
260 popup = popup.item(
261 PopupMenuItem::new(if fitted { "Fill frame" } else { "Fit to frame" })
262 .icon(if fitted { IconName::Expand } else { IconName::Shrink })
263 .on_click(move |_, _, cx| {
264 fit_app.update(cx, |state, cx| state.toggle_call_fit(&fit_mri, cx))
265 }),
266 );
267 }
252 268 if organizes {
253 269 let (spotlight_app, spotlight_mri) = (app.clone(), mri.to_owned());
254 270 popup = popup.item(
@@ -249,6 +249,22 @@ pub fn tile_menu(
249 pin_app.update(cx, |state, cx| state.toggle_call_pin(&pin_mri, cx))
249 pin_app.update(cx, |state, cx| state.toggle_call_pin(&pin_mri, cx))
250 }),
250 }),
251 );
251 );
252 if model.is_one_to_one()
253 || model
254 .tiles
255 .iter()
256 .any(|tile| tile.mri == mri && tile.has_video)
257 {
258 let (fit_app, fit_mri) = (app.clone(), mri.to_owned());
259 let fitted = model.is_fitted(mri);
260 popup = popup.item(
261 PopupMenuItem::new(if fitted { "Fill frame" } else { "Fit to frame" })
262 .icon(if fitted { IconName::Expand } else { IconName::Shrink })
263 .on_click(move |_, _, cx| {
264 fit_app.update(cx, |state, cx| state.toggle_call_fit(&fit_mri, cx))
265 }),
266 );
267 }
252 if organizes {
268 if organizes {
253 let (spotlight_app, spotlight_mri) = (app.clone(), mri.to_owned());
269 let (spotlight_app, spotlight_mri) = (app.clone(), mri.to_owned());
254 popup = popup.item(
270 popup = popup.item(
crates/app/src/views/call_view.rs +8 −1
@@ -97,6 +97,7 @@ struct TileExtras {
97 97 reaction: Option<(Reaction, u64)>,
98 98 spotlight: bool,
99 99 pinned: bool,
100 fitted: bool,
100 101 }
101 102
102 103 fn hand_badge(position: usize, own: bool) -> Div {
@@ -253,7 +254,11 @@ fn video_tile(
253 254 .child(
254 255 img(ImageSource::Render(image))
255 256 .size_full()
256 .object_fit(ObjectFit::Cover)
257 .object_fit(if extras.fitted {
258 ObjectFit::Contain
259 } else {
260 ObjectFit::Cover
261 })
257 262 .rounded(px(TILE_RADIUS)),
258 263 )
259 264 .child(
@@ -992,6 +997,7 @@ pub(super) fn plain_person_tile(
992 997 .map(|chip| (chip.reaction.clone(), chip.serial)),
993 998 spotlight: remote.spotlight.is_some(),
994 999 pinned: model.is_pinned(&remote.mri),
1000 fitted: model.is_fitted(&remote.mri),
995 1001 };
996 1002 person_tile_body(state, model, remote, size, now, &extras)
997 1003 }
@@ -1081,6 +1087,7 @@ pub(super) fn plain_own_tile(
1081 1087 reaction: model.own_chip(now).map(|chip| (chip.reaction.clone(), chip.serial)),
1082 1088 spotlight: model.own_spotlight.is_some(),
1083 1089 pinned: model.is_pinned(own_mri),
1090 fitted: false,
1084 1091 };
1085 1092 own_tile_body(state, model, size, now, &extras)
1086 1093 }
@@ -97,6 +97,7 @@ struct TileExtras {
97 reaction: Option<(Reaction, u64)>,
97 reaction: Option<(Reaction, u64)>,
98 spotlight: bool,
98 spotlight: bool,
99 pinned: bool,
99 pinned: bool,
100 fitted: bool,
100}
101}
101
102
102fn hand_badge(position: usize, own: bool) -> Div {
103fn hand_badge(position: usize, own: bool) -> Div {
@@ -253,7 +254,11 @@ fn video_tile(
253 .child(
254 .child(
254 img(ImageSource::Render(image))
255 img(ImageSource::Render(image))
255 .size_full()
256 .size_full()
256 .object_fit(ObjectFit::Cover)
257 .object_fit(if extras.fitted {
258 ObjectFit::Contain
259 } else {
260 ObjectFit::Cover
261 })
257 .rounded(px(TILE_RADIUS)),
262 .rounded(px(TILE_RADIUS)),
258 )
263 )
259 .child(
264 .child(
@@ -992,6 +997,7 @@ pub(super) fn plain_person_tile(
992 .map(|chip| (chip.reaction.clone(), chip.serial)),
997 .map(|chip| (chip.reaction.clone(), chip.serial)),
993 spotlight: remote.spotlight.is_some(),
998 spotlight: remote.spotlight.is_some(),
994 pinned: model.is_pinned(&remote.mri),
999 pinned: model.is_pinned(&remote.mri),
1000 fitted: model.is_fitted(&remote.mri),
995 };
1001 };
996 person_tile_body(state, model, remote, size, now, &extras)
1002 person_tile_body(state, model, remote, size, now, &extras)
997}
1003}
@@ -1081,6 +1087,7 @@ pub(super) fn plain_own_tile(
1081 reaction: model.own_chip(now).map(|chip| (chip.reaction.clone(), chip.serial)),
1087 reaction: model.own_chip(now).map(|chip| (chip.reaction.clone(), chip.serial)),
1082 spotlight: model.own_spotlight.is_some(),
1088 spotlight: model.own_spotlight.is_some(),
1083 pinned: model.is_pinned(own_mri),
1089 pinned: model.is_pinned(own_mri),
1090 fitted: false,
1084 };
1091 };
1085 own_tile_body(state, model, size, now, &extras)
1092 own_tile_body(state, model, size, now, &extras)
1086}
1093}