From 8a045594ddaa23d2434636a614eeb8a4e40edfdc Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Wed, 18 Nov 2026 21:02:54 +0000 Subject: [PATCH] ribbon-w3: net change of 6 commits - ribbon-w3: written by an agent - ribbon-w3: finished by an agent - ribbon-w3: finished by an agent - ribbon-w3: finished by an agent - ribbon-w3: finished by an agent - ribbon-w3: finished by an agent --- crates/menu/src/ribbon.rs | 312 +++++++++++++++-- crates/menu/src/ribbon/group.rs | 120 ++++++- crates/menu/src/ribbon/plan.rs | 11 +- crates/menu/src/ribbon/stories.rs | 149 ++++++++ crates/menu/tests/it/main.rs | 3 + crates/menu/tests/it/ribbon.rs | 329 ++++++++++++++++++ crates/theme/src/dump.rs | 4 +- crates/theme/src/resolve.rs | 1 + crates/theme/src/tokens/type_motion.rs | 4 + crates/theme/src/values.rs | 3 + crates/ui-contract/src/contract/cx/context.rs | 8 + crates/ui-contract/src/contract/mod.rs | 1 + crates/ui-contract/src/contract/steps.rs | 1 + .../src/contract/steps/scroll_owner.rs | 18 + crates/ui-contract/src/layout/body.rs | 142 +++++++- crates/ui-contract/src/layout/mod.rs | 2 +- crates/ui-contract/src/runtime/env.rs | 6 +- crates/ui-contract/src/runtime/keys.rs | 2 +- .../ui-contract/src/runtime/keys/intents.rs | 5 + crates/ui-contract/src/runtime/memory.rs | 8 + .../ui-widgets/tests/it/contract/levelled.rs | 65 ++++ crates/ui-widgets/tests/it/contract/mod.rs | 1 + 22 files changed, 1138 insertions(+), 57 deletions(-) create mode 100644 crates/menu/src/ribbon/stories.rs create mode 100644 crates/menu/tests/it/ribbon.rs create mode 100644 crates/ui-widgets/tests/it/contract/levelled.rs diff --git a/crates/menu/src/ribbon.rs b/crates/menu/src/ribbon.rs index 6e427f9ed..8a5705ca9 100644 --- a/crates/menu/src/ribbon.rs +++ b/crates/menu/src/ribbon.rs @@ -3,24 +3,42 @@ mod gallery; mod group; mod plan; +#[cfg(feature = "screen-testing")] +mod stories; +use std::borrow::Cow; use std::fmt::Debug; use std::hash::Hash; -use std::marker::PhantomData; use std::sync::Arc; +use craft_behavior::{CanvasTransform, EditEvent, IconId, Metrics, Mixed, SelectionChange, Sense, keyed}; use craft_keymap::CommandRef; -use craft_ui::contract::Bind; -use craft_ui::runtime::env::Label; +use craft_ui::buttons::IconButton; +use craft_ui::contract::{ + Access, Bind, CollectionEvent, Common, Component, Container, ContainerProps, Cx, NoValue, Outcome, Props as _, Role, Scroll, + Show as _, ShowCollection as _, ShowContainer as _, Sizing, clicked, scroll_step, +}; +use craft_ui::layout_components::Row; +use craft_ui::runtime::env::{Env, Label}; use craft_ui::runtime::inspect; -use craft_ui::tabs::{StripEnd, TabRole}; -use egui::{Id, Pos2, Rect, Ui}; +use craft_ui::runtime::motion::{Animate as _, spec}; +use craft_ui::style::{ComponentStyle, StyleCx}; +use craft_ui::tabs::{StripEnd, Tab, TabKind, TabRole, TabStrip, TabStripOutput}; +use egui::{Id, Pos2, Rect, Response, Ui, Vec2, vec2}; pub use craft_ui::buttons::GroupLevel; pub use gallery::{Gallery, GalleryFace, GalleryItem, GalleryMore, GalleryOutput}; pub use group::RibbonGroup; pub use plan::{GroupWidths, plan}; +craft_ui::words! { + /// The words of the ribbon's own controls. + struct RibbonWords { + scroll_left: "ribbon.scrollLeft" = "Scroll left"; + scroll_right: "ribbon.scrollRight" = "Scroll right"; + } +} + /// The ribbon: a [`TabKind::Ribbon`](craft_ui::tabs::TabKind) strip over a scrolling group row, /// with minimise and context requests. The strip and the row show inside one inspected region /// (`inspect::record`), whose record ([`RibbonOutput::controls`]) gives each control's rect and @@ -28,58 +46,213 @@ pub use plan::{GroupWidths, plan}; /// relative to the old one (mirrored in right-to-left), through one `Tween`; with reduce motion the /// new content shows at rest. #[must_use = "show the ribbon with `show`"] +#[derive(craft_ui::contract::Pattern)] +#[pattern(probe(Ribbon<'static, usize>))] pub struct Ribbon<'a, T: Clone + Eq + Hash + Send + Sync + Debug + 'static> { - stub: PhantomData<(&'a (), T)>, + label: Label, + tabs: &'a [RibbonTab], + shown: Bind<'a, T>, + trailing: &'a [StripEnd<'a>], + minimised: Option>, } impl<'a, T: Clone + Eq + Hash + Send + Sync + Debug + 'static> Ribbon<'a, T> { /// A ribbon named `label` over `tabs`, showing the tab `shown` binds. pub fn new(label: impl Into