diff --git a/crates/text/tests/it/editor.rs b/crates/text/tests/it/editor.rs index 698376b281..85b7e945d7 100644 --- a/crates/text/tests/it/editor.rs +++ b/crates/text/tests/it/editor.rs @@ -661,11 +661,12 @@ fn field_modes_end_on_enter_tab_and_shift_tab_but_not_while_composing() { } /// The canvas editor keeps Shift+Tab only for a host with its own Tab: on any other host Shift+Tab moves the focus out -/// of the editor and types nothing. +/// of the editor and types nothing. A second editor beside it gives the focus somewhere to go: Tab order wraps, so the +/// only stop in a window would take the focus back. #[trial] fn shift_tab_leaves_a_canvas_editor_whose_host_has_no_tab_keys() { use craft_ui::testing::access::{focused_key, name}; - let mut editor = session_on(Host { text: "abc".to_owned(), ..Host::default() }, None, false, EditorMode::Canvas, false); + let mut editor = session_on(Host { text: "abc".to_owned(), ..Host::default() }, None, true, EditorMode::Canvas, false); editor.focus(); let focused = |editor: &Session| name(editor.fixture.tree(), focused_key(editor.fixture.tree())).map(str::to_owned); assert_eq!(focused(&editor).as_deref(), Some("Text"), "the editor has the focus"); diff --git a/crates/ui-contract/src/contract/items/keys.rs b/crates/ui-contract/src/contract/items/keys.rs index 90f0631b24..3773a3bb65 100644 --- a/crates/ui-contract/src/contract/items/keys.rs +++ b/crates/ui-contract/src/contract/items/keys.rs @@ -152,11 +152,13 @@ impl ItemsHooks<'_, '_, C> { self.column_keys(cx, lead_at.filter(|_| !header_held)); // The pass's `update_inputs` turned an `Activate` intent into the keyed activation. let activated = cx.core.intents.take(Intent::Activate) || cx.core.activation.is_some_and(|activation| activation.by_key); - // A disabled lead does not run, as a press on it does not. + // A disabled lead does not run, as a press on it does not: the collection is not activated, so the popup or menu + // it is in stays open. if activated && !header_held && let Some(row) = lead_at.filter(|&row| !self.source.enabled(row)) { + cx.core.activation = None; self.events.push(CollectionEvent::Refused(self.source.key(row))); } else if activated && !header_held diff --git a/crates/ui-widgets/src/list/row/paint.rs b/crates/ui-widgets/src/list/row/paint.rs index 89ba20395a..6f83fd8ec4 100644 --- a/crates/ui-widgets/src/list/row/paint.rs +++ b/crates/ui-widgets/src/list/row/paint.rs @@ -116,7 +116,7 @@ impl ListRow<'_> { pub(super) fn paint_thumbs(&mut self, ui: &mut PaintUi<'_>, cx: &Cx<'_, Self>, placed: &Placed, ink: StyleColor) { let style = cx.style; - let frame = style.thumb_frame_width; + let frame = style.sizes.thumb_frame; let outset = style.sizes.tight; let arm = style.sizes.gap; let rects: Vec = placed.first.into_iter().chain(placed.extras.iter().map(|(thumb, _)| *thumb)).collect(); diff --git a/crates/ui-widgets/src/list/row/placement.rs b/crates/ui-widgets/src/list/row/placement.rs index 48d5df4a87..7c1a2c4bed 100644 --- a/crates/ui-widgets/src/list/row/placement.rs +++ b/crates/ui-widgets/src/list/row/placement.rs @@ -3,7 +3,7 @@ use super::ListRow; use super::show::named; use super::style::{ListRowStyle, ThumbRows}; -use super::thumb::{Thumb, ThumbSize}; +use super::thumb::{Thumb, ThumbAspect, ThumbSize}; use super::trailing::{TrailingFace, TrailingItem, trailing_run}; use crate::buttons::Link; use crate::contract::{ColumnAlign, PartsCx, RowHeight, WordSetCx as _}; @@ -37,6 +37,8 @@ pub(super) struct Sizes { pub(super) min_label: f32, thumbs: [f32; 3], thumb_pad: f32, + /// The width of the frame drawn on a thumbnail slot's edge, inside which the picture lies. + pub(super) thumb_frame: f32, /// The least height of a row with a thumbnail. thumb_row: f32, pub(super) tight: f32, @@ -70,6 +72,7 @@ impl Sizes { min_label: MIN_LABEL_HEIGHTS * control.height, thumbs: [thumbs.sm, thumbs.md, thumbs.lg], thumb_pad: if tight { tokens.space.gap.tight } else { tokens.space.gap.stack }, + thumb_frame: tokens.stroke.thin, // A standard control and the panel padding, as the old `thumb_row_min`. thumb_row: if tight { row } else { tokens.size.control.md + tokens.space.pad.regular }, tight: tokens.space.gap.tight, @@ -92,6 +95,12 @@ impl Sizes { thumb.pick(self.thumbs) } + /// The width of a thumbnail slot `side` high whose picture, inside the slot's frame, has `aspect`. + fn thumb_width(&self, side: f32, aspect: ThumbAspect) -> f32 { + let frame = 2.0 * self.thumb_frame; + aspect.of((side - frame).max(0.0)) + frame + } + /// The height of a row with a thumbnail of `thumb` and, if `detail`, a detail line: the row height, the thumbnail /// with its padding (at least `thumb_row`), or the two lines of text, whichever is tallest. pub(super) fn height(&self, thumb: ThumbSize, detail: bool) -> f32 { @@ -218,7 +227,7 @@ impl ListRow<'_> { fn leading(&self, sizes: &Sizes, widths: &Widths) -> Option { let side = sizes.side(self.thumb); if self.shows_thumbs(sizes) { - let first = self.thumb_aspect.of(side); + let first = sizes.thumb_width(side, self.thumb_aspect); let between = |extra: &Thumb<'_>| if extra.link.is_some() { sizes.icon } else { sizes.gap }; Some(first + self.extras.iter().map(|extra| first + between(extra)).sum::()) } else if let Some(lead) = widths.lead { @@ -251,7 +260,7 @@ impl ListRow<'_> { /// The thumbnail width and height of this row. pub(super) fn thumb_size(&self, sizes: &Sizes) -> Vec2 { let side = sizes.side(self.thumb); - Vec2::new(self.thumb_aspect.of(side), side) + Vec2::new(sizes.thumb_width(side, self.thumb_aspect), side) } /// The height the line of components under the text takes with the gap above it; 0 without one. @@ -623,6 +632,7 @@ pub fn placement_under_fixed_sizes(row: &ListRow<'_>, width: f32, rtl: bool) -> min_label: 60.0, thumbs: [24.0, 32.0, 48.0], thumb_pad: 4.0, + thumb_frame: 1.0, thumb_row: 28.0, tight: 2.0, gap_row: 0.0, diff --git a/crates/ui-widgets/src/list/row/show.rs b/crates/ui-widgets/src/list/row/show.rs index e88d35a5be..6da25c060f 100644 --- a/crates/ui-widgets/src/list/row/show.rs +++ b/crates/ui-widgets/src/list/row/show.rs @@ -111,7 +111,6 @@ impl Component for ListRow<'_> { cell_muted: TextLook::new(role, ink(muted)), thumb_frame: c(colors.line.frame), - thumb_frame_width: tokens.stroke.thin, separator: crate::display::divider::SeparatorRule::of(cx), sizes, } diff --git a/crates/ui-widgets/src/list/row/style.rs b/crates/ui-widgets/src/list/row/style.rs index 3942613e78..58e989aed7 100644 --- a/crates/ui-widgets/src/list/row/style.rs +++ b/crates/ui-widgets/src/list/row/style.rs @@ -46,7 +46,6 @@ pub struct ListRowStyle { /// The frame at the edge of each thumbnail's slot, around its picture: `line.frame`, `stroke.thin` wide. pub(super) thumb_frame: StyleColor, - pub(super) thumb_frame_width: f32, /// The rule of a separator row and its room, as a menu's separator has. pub(super) separator: SeparatorRule, pub(super) sizes: Sizes,