mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-30 18:27:00 +01:00
Merge branch 'port/deckcraft/red/fw-r8' into port/deckcraft/area/framework
This commit is contained in:
commit
1b3ebaae06
6 files changed
+20
-9
No files matched your search
@@ -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");
|
||||
|
||||
@@ -152,11 +152,13 @@ impl<C: Collection> 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
|
||||
|
||||
@@ -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<Rect> = placed.first.into_iter().chain(placed.extras.iter().map(|(thumb, _)| *thumb)).collect();
|
||||
|
||||
@@ -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<f32> {
|
||||
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::<f32>())
|
||||
} 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,
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user