Forms: an option list stays inside the window; media ratios are checked in one place

The floating list under a Select, Combobox or MultiSelect was at least its
trigger's width with no ceiling, so a long choice ran it past the window
and its rows never ellipsized. It now stops at the window's width less the
window margin on each side, so gpui snaps it inside. The camera preview
and the model viewer check their ratio through primitives::checked_ratio.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-09-26 19:17:52 -04:00
1 parent 7f1cfe8c3d
commit 9872adc5e9
6 files changed
+37 -7

No files matched your search

+2 -3
View File
@@ -7,7 +7,7 @@ use gpui::{
use crate::{
forms::{Choice, OnValue, Select},
primitives::{Icon, IconName, framed},
primitives::{Icon, IconName, checked_ratio, framed},
theme::{ActiveTheme, IconSize, Radius, TextSize},
typography::Ellipsis,
};
@@ -24,10 +24,9 @@ pub struct CameraPreview {
impl CameraPreview {
/// `ratio` is the camera's width over its height.
pub fn new(id: impl Into<ElementId>, ratio: f32) -> Self {
assert!(ratio > 0.0, "a camera's shape of {ratio}");
Self {
id: id.into(),
ratio,
ratio: checked_ratio(ratio),
frame: None,
name: None,
}
+2 -3
View File
@@ -11,7 +11,7 @@ use crate::{
layout::seeded::use_seeded,
motion::Spinner,
overlays::media_button,
primitives::{FocusRing, IconName, framed, tab_stop},
primitives::{FocusRing, IconName, checked_ratio, framed, tab_stop},
theme::{ActiveTheme, ControlSize, Radius},
};
@@ -70,7 +70,6 @@ pub struct ModelViewer {
impl ModelViewer {
/// `ratio` is the view's width over its height.
pub fn new(id: impl Into<ElementId>, ratio: f32, orbit: Orbit) -> Self {
assert!(ratio > 0.0, "a view's shape of {ratio}");
assert!(
(NEAR..=FAR).contains(&orbit.distance),
"a distance of {}",
@@ -78,7 +77,7 @@ impl ModelViewer {
);
Self {
id: id.into(),
ratio,
ratio: checked_ratio(ratio),
frame: None,
orbit,
on_orbit: None,