rc-chrome-w4: red round 3 fix (chrome-run-3-fw)

This commit is contained in:
Martin Ball
2026-11-18 16:40:16 +00:00
parent 8bd0518201
commit 01bb138f35
6 changed files with 18 additions and 6 deletions
@@ -209,7 +209,7 @@ impl<C: Collection> ShapeHooks<C> 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()));
@@ -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<Vec2>, 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
+3 -2
View File
@@ -634,8 +634,9 @@ pub trait Collection: Component + HasProps + Meta<Shape = shape::Items> {
}
/// 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<Vec2>, _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<Vec2>, _rows: usize, _cx: &StyleCx<'_>) -> f32 {
0.0
}
+1 -1
View File
@@ -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<Vec2>, cx: &StyleCx<'_>) -> f32 {
fn ideal_width(&self, _item: Option<Vec2>, _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
+11
View File
@@ -567,6 +567,17 @@ impl<K: Clone + Eq + Hash + Send + Sync + std::fmt::Debug + 'static> 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<Vec2>, 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<BindMut<'_, Selection<K>>> {
self.held = Bind::given(self.shown.clone().map_or_else(Selection::default, Selection::single));
+1 -1
View File
@@ -798,7 +798,7 @@ impl<K: Clone + Eq + Hash + Send + Sync + 'static> 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<Vec2>, cx: &StyleCx<'_>) -> f32 {
fn ideal_width(&self, item: Option<Vec2>, _rows: usize, cx: &StyleCx<'_>) -> f32 {
if self.card_columns == 0 {
return 0.0;
}