From 01bb138f351005f0030a0b7df90f3a4bc8b97928 Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Wed, 18 Nov 2026 16:40:16 +0000 Subject: [PATCH] rc-chrome-w4: red round 3 fix (chrome-run-3-fw) --- crates/ui-contract/src/contract/items/hooks.rs | 2 +- crates/ui-contract/src/contract/items/measure.rs | 2 +- crates/ui-contract/src/contract/mod.rs | 5 +++-- crates/ui-widgets/src/choice/swatch_table.rs | 2 +- crates/ui-widgets/src/tabs/strip.rs | 11 +++++++++++ crates/ui-widgets/src/tile_grid/grid.rs | 2 +- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/crates/ui-contract/src/contract/items/hooks.rs b/crates/ui-contract/src/contract/items/hooks.rs index ce7f01bfe..5f7dd5bc1 100644 --- a/crates/ui-contract/src/contract/items/hooks.rs +++ b/crates/ui-contract/src/contract/items/hooks.rs @@ -209,7 +209,7 @@ impl ShapeHooks for ItemsHooks<'_, '_, C> { // Columns side by side at their own widths: a `Content` column takes its widest cell, not the share of // the widest row it would get. let columns = if self.header.has_columns() { self.header.content_width() } else { 0.0 }; - widest.max(columns).max(comp.ideal_width(item, scx)).max(floor).min(room.x) + widest.max(columns).max(comp.ideal_width(item, self.source.len(), scx)).max(floor).min(room.x) } }; let previous = self.layout.take().or_else(|| self.previous.take()).map(|held| Arc::try_unwrap(held).unwrap_or_else(|held| (*held).clone())); diff --git a/crates/ui-contract/src/contract/items/measure.rs b/crates/ui-contract/src/contract/items/measure.rs index 3fefcf765..a29b9bcaa 100644 --- a/crates/ui-contract/src/contract/items/measure.rs +++ b/crates/ui-contract/src/contract/items/measure.rs @@ -40,7 +40,7 @@ impl<'s, 'r, C: Collection> ItemsHooks<'s, 'r, C> { /// the width the column settles on. pub(super) fn width_from_content(&mut self, comp: &C, ui: &Ui, id: Id, room: Vec2, item: Option, scx: &StyleCx<'_>) -> f32 { let rows = if self.header.has_columns() { self.header.least_width() } else { self.largest_in(comp, ui, id, room).x }; - rows.max(comp.ideal_width(item, scx)).min(room.x) + rows.max(comp.ideal_width(item, self.source.len(), scx)).min(room.x) } /// The largest ideal size of the rows in this pass, and the widest cell each column's items reported: each row is diff --git a/crates/ui-contract/src/contract/mod.rs b/crates/ui-contract/src/contract/mod.rs index 0f85777cc..dbea6fe56 100644 --- a/crates/ui-contract/src/contract/mod.rs +++ b/crates/ui-contract/src/contract/mod.rs @@ -634,8 +634,9 @@ pub trait Collection: Component + HasProps + Meta { } /// The width the collection asks for when it takes its width from its content, over its widest row: a grid of - /// cards asks for its declared number of columns. 0 asks for nothing. `item` is as `item_layout_from` gets it. - fn ideal_width(&self, _item: Option, _cx: &StyleCx<'_>) -> f32 { + /// cards asks for its declared number of columns. 0 asks for nothing. `item` is as `item_layout_from` gets it; + /// `rows` is the number of rows the source holds, for a collection whose rows stand side by side. + fn ideal_width(&self, _item: Option, _rows: usize, _cx: &StyleCx<'_>) -> f32 { 0.0 } diff --git a/crates/ui-widgets/src/choice/swatch_table.rs b/crates/ui-widgets/src/choice/swatch_table.rs index 8b9b56e4f..265251102 100644 --- a/crates/ui-widgets/src/choice/swatch_table.rs +++ b/crates/ui-widgets/src/choice/swatch_table.rs @@ -217,7 +217,7 @@ impl Collection for SwatchTable<'_> { /// Where the table takes its width from its content it asks for every cell in one row, or its count per row: the /// room it is offered then wraps the cells, as it does where it is given the width. - fn ideal_width(&self, _item: Option, cx: &StyleCx<'_>) -> f32 { + fn ideal_width(&self, _item: Option, _rows: usize, cx: &StyleCx<'_>) -> f32 { let columns = self.per_row.map_or(self.swatches.len(), |columns| columns.max(1).min(self.swatches.len())); // Half a point over, so the division that counts the columns back never rounds below `columns`. columns as f32 * self.cell(cx) + 0.5 diff --git a/crates/ui-widgets/src/tabs/strip.rs b/crates/ui-widgets/src/tabs/strip.rs index d6d43a24a..bf60a344b 100644 --- a/crates/ui-widgets/src/tabs/strip.rs +++ b/crates/ui-widgets/src/tabs/strip.rs @@ -567,6 +567,17 @@ impl Collection &self.items } + /// The strip asks for the largest tab's size, which `ideal_width` reads. + fn measures_items(&self) -> bool { + true + } + + /// Where the strip takes its width from its content (a dialog sized by what it holds), every tab fits in a row: + /// as many as the source holds, each as wide as the widest, so the strip does not send tabs to its overflow menu. + fn ideal_width(&self, item: Option, rows: usize, _: &StyleCx<'_>) -> f32 { + item.map_or(0.0, |largest| largest.x * rows as f32) + } + /// The shown tab is the single selection; the strip reports a change and the host applies it. fn selection(&mut self) -> Option>> { self.held = Bind::given(self.shown.clone().map_or_else(Selection::default, Selection::single)); diff --git a/crates/ui-widgets/src/tile_grid/grid.rs b/crates/ui-widgets/src/tile_grid/grid.rs index f02ea9d77..cdb26700a 100644 --- a/crates/ui-widgets/src/tile_grid/grid.rs +++ b/crates/ui-widgets/src/tile_grid/grid.rs @@ -798,7 +798,7 @@ impl Collection for TileGrid<'_, K } /// The last layout again while the width, the rows stamp and everything the arrangement reads are the same. - fn ideal_width(&self, item: Option, cx: &StyleCx<'_>) -> f32 { + fn ideal_width(&self, item: Option, _rows: usize, cx: &StyleCx<'_>) -> f32 { if self.card_columns == 0 { return 0.0; }