diff --git a/crates/ui-contract/src/contract/collection/props.rs b/crates/ui-contract/src/contract/collection/props.rs index f37640b73..a4df19641 100644 --- a/crates/ui-contract/src/contract/collection/props.rs +++ b/crates/ui-contract/src/contract/collection/props.rs @@ -240,6 +240,9 @@ pub struct CollectionProps { pub notch: Option, /// What a middle press does: pan or latched auto-scroll. pub middle_button: MiddleButton, + /// Only a primary press picks an item: a secondary click asks for the item's menu and leaves the selection, and a + /// middle press picks nothing. Off, every button's press picks the item under it. + pub primary_picks: bool, /// Flip the direction of middle-button pan and auto-scroll. pub invert_middle: bool, /// The axis the rows overflow along. A collection owns the scroll along it, so it sits only in a scrolling body @@ -334,6 +337,7 @@ impl CollectionProps { command_click: false, notch: None, middle_button: MiddleButton::Pan, + primary_picks: false, invert_middle: false, overflow: Axis::Y, pages: false, @@ -589,6 +593,13 @@ impl CollectionProps { self } + /// Whether only a primary press picks an item (see [`CollectionProps::primary_picks`]). + #[must_use] + pub const fn primary_picks(mut self, on: bool) -> Self { + self.primary_picks = on; + self + } + /// Flips the direction of middle-button pan and auto-scroll (see [`CollectionProps::invert_middle`]). #[must_use] pub const fn invert_middle(mut self, on: bool) -> Self { diff --git a/crates/ui-contract/src/contract/items/press.rs b/crates/ui-contract/src/contract/items/press.rs index a36b54ffa..9f4ab2f4e 100644 --- a/crates/ui-contract/src/contract/items/press.rs +++ b/crates/ui-contract/src/contract/items/press.rs @@ -102,7 +102,7 @@ impl ItemsHooks<'_, '_, C> { // A command on the row, reported when the press ends as a click; the selection stays. self.drags.command = Some(self.source.key(at)); self.move_lead(at, LeadSource::Pointer); - } else if !secondary_on_toggle { + } else if !secondary_on_toggle && (primary || !props.primary_picks) { let mods = crate::runtime::pointer::frame(&ctx).mods; let key = self.source.key(at); let column = if Self::selects_cells(comp) { layout.column_at(local(start.origin), offset) } else { None }; @@ -299,7 +299,7 @@ impl ItemsHooks<'_, '_, C> { if let Some((pos, Some(at))) = menu_row && self.source.enabled(at) { - if !self.holds(at) && self.toggle_cell(props, layout, at, offset, local(pos)).is_none() { + if !props.primary_picks && !self.holds(at) && self.toggle_cell(props, layout, at, offset, local(pos)).is_none() { let column = if Self::selects_cells(comp) { layout.column_at(local(pos), offset) } else { None }; match column { Some(column) => self.cell_press(comp, layout, at, column, false, false), diff --git a/crates/ui-panels/src/docking/config.rs b/crates/ui-panels/src/docking/config.rs index 51c0a8886..581a867c9 100644 --- a/crates/ui-panels/src/docking/config.rs +++ b/crates/ui-panels/src/docking/config.rs @@ -1,6 +1,7 @@ //! `DockConfig`: how a dock behaves, apart from how it looks (the dock's `ComponentStyle`) and what it says //! (`DockWords`). +use super::IconicMode; use super::targets::ZoneRule; use craft_behavior::DockSide; @@ -84,6 +85,9 @@ pub struct DockConfig { pub native_windows: bool, /// Docked groups' menus get Minimize and Move Group Up and Down. pub group_order_items: bool, + /// What the icons of a docked column collapsed to icons open: flyouts, or with [`IconicMode::Rail`] the column + /// itself, whose icons then stay beside it while it is expanded. Floating windows' icons open flyouts. + pub iconic_mode: IconicMode, } impl Default for DockConfig { @@ -102,11 +106,19 @@ impl Default for DockConfig { wheel_selects_tabs: false, native_windows: true, group_order_items: false, + iconic_mode: IconicMode::Flyouts, } } } impl DockConfig { + /// What the icons of docked iconic columns open. + #[must_use] + pub fn iconic_mode(mut self, mode: IconicMode) -> Self { + self.iconic_mode = mode; + self + } + /// The Minimize and Move Group Up and Down items of docked groups' menus on or off. #[must_use] pub fn group_order_items(mut self, on: bool) -> Self { diff --git a/crates/ui-panels/src/docking/group.rs b/crates/ui-panels/src/docking/group.rs index 4ac13aeb1..2cc36a005 100644 --- a/crates/ui-panels/src/docking/group.rs +++ b/crates/ui-panels/src/docking/group.rs @@ -8,12 +8,14 @@ use super::words::DockWords; use super::{PanelDrag, PanelKey, PanelTitle}; use crate::buttons::IconButton; use crate::contract::{ - Access, Bind, BindMut, BodyCx, Common, Component, Container, ContainerProps, ContextMenuRequest, Cx, HeaderEdge, HeaderParts, HeaderRegion, + Access, Bind, BindMut, BodyCx, Common, Component, Container, ContainerProps, ContextMenuRequest, Cx, FooterRegion, HeaderEdge, HeaderParts, + HeaderRegion, ListDrag, MeasureCx, Name, Outcome, OverlayUi, Overlays as _, PaintUi, PartsCx, Pointer as _, PopupKind, Props as _, Role, ShowCollection as _, ShowContainer as _, Sizing, WordSetCx as _, }; use crate::menu::{GroupItem, Menu, PanelMenu, PanelRow}; use crate::runtime::commands::{self, CommandSet as _, CommandState, Commands as _}; +use crate::sections::FooterBar; use crate::runtime::env::Label; use crate::runtime::focus::{self, FocusTarget}; use crate::style::{ComponentStyle, Corners, StyleCx, SurfaceKind}; @@ -260,6 +262,8 @@ pub struct DockGroup<'a, P: Clone + Hash + Send + Sync + 'static> { /// The host's items before the tab strip. #[prop(func = "FnMut(&mut egui::Ui, &mut BodyCx<'_>)")] extra: Option>, + /// The shown panel's footer, pinned under the body: [`footer`](DockGroup::footer). + footer: Option>, /// The size of the group this pass, for the drag ghost. size: Vec2, reported: Reported, @@ -290,12 +294,22 @@ impl<'a, P: Clone + Hash + Send + Sync + 'static> DockGroup<'a, P> { panel_menu_shown: true, command_states: Vec::new(), extra: None, + footer: None, size: Vec2::ZERO, reported: Reported::default(), } .label(title) } + /// The shown panel's footer: the closure fills a footer bar pinned under the body, across the group, that stays in + /// view while the body scrolls. A minimized group shows none. + #[must_use] + pub fn footer(mut self, content: impl FnMut(&mut Ui, &mut BodyCx<'_>) + 'a) -> Self { + self.props = self.props.footer(FooterRegion::new()); + self.footer = Some(Box::new(content)); + self + } + /// Whether the panel menu button shows: it is asked for and the menu has rows. fn shows_menu_button(&self) -> bool { self.panel_menu_shown && !self.menu.is_empty() @@ -446,6 +460,12 @@ impl Container for DockGroup<'_, P> { HeaderParts::NONE.end(band + button) } + fn footer(&mut self, ui: &mut Ui, _: &mut BodyCx<'_>) { + if let Some(content) = self.footer.as_mut() { + FooterBar::body().show(ui, |ui, bar| content(ui, bar)); + } + } + /// The host's items and the tab strip, on one line. fn header(&mut self, ui: &mut Ui, cx: &mut BodyCx<'_>) { for (command, state) in self.command_states.drain(..) { diff --git a/crates/ui-panels/src/docking/iconic.rs b/crates/ui-panels/src/docking/iconic.rs index f42209416..6d1329b3f 100644 --- a/crates/ui-panels/src/docking/iconic.rs +++ b/crates/ui-panels/src/docking/iconic.rs @@ -80,6 +80,19 @@ impl IconicSizes { } } +/// What the icons of an iconic column open. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] +#[non_exhaustive] +pub enum IconicMode { + /// A click on an icon opens its panel in a flyout beside the collapsed column. + #[default] + Flyouts, + /// The icons are a rail that stays beside the column when it expands: a click on an icon expands the column with + /// that panel in front of its group, and a click on the icon of a panel in front of the expanded column collapses + /// the column again. The column opens no flyouts. + Rail, +} + /// What an iconic column reports. #[derive(Debug)] #[non_exhaustive] @@ -89,8 +102,12 @@ pub struct IconicColumnOutput

{ pub edit: EditResponse>, /// The rect the column took, for `DockAreaOutput::columns`. pub placed: Rect, - /// The user asked to expand the column (`false`); the host sets `Column::iconic`. + /// The user asked to expand the column (`false`), or in [`IconicMode::Rail`] to collapse the expanded column + /// (`true`); the host sets `Column::iconic`. pub iconic: Option, + /// In [`IconicMode::Rail`], the panel whose icon the user chose to bring to the front of its group; the host + /// makes it its group's active panel. + pub front: Option

, /// The dock row the user picked in the column menu. pub picked: Option, /// The width the user gave the iconic column on its inner edge this pass. @@ -163,6 +180,11 @@ pub struct IconicColumnStyle { /// /// In a floating window ([`ColumnBar::Window`]) the window's title row is the column's bar: the column shows its /// icons under it and keeps the divider of its inner edge, which sets its width, and registers no edge bands. +/// +/// In [`IconicMode::Rail`] the icons open no flyouts and the bound open panel is not used: the column is a rail the +/// host also shows beside the expanded column. While `Column::iconic` is off the panels in front of their groups show +/// selected and the bar's chevron collapses the column; a click on an icon reports +/// [`IconicColumnOutput::front`] and [`IconicColumnOutput::iconic`]. #[derive(crate::contract::Component, crate::contract::Props)] #[component(container, overlay, probe(IconicColumn<'static, u8>))] pub struct IconicColumn<'a, P: Value + Hash + 'static> { @@ -187,6 +209,9 @@ pub struct IconicColumn<'a, P: Value + Hash + 'static> { /// Whether Auto-Collapse Iconic Panels is on. #[prop] auto_collapse: bool, + /// What the icons open: flyouts, or the column itself as a rail. + #[prop] + mode: IconicMode, /// The rect the dock may grow within, which bounds how wide its inner edge can make the column. #[prop] within: Rect, @@ -203,6 +228,10 @@ pub struct IconicColumn<'a, P: Value + Hash + 'static> { expand: bool, /// The size the user gave the open flyout this pass. flyout: Option>, + /// In rail mode, what a click on an icon asked for this pass: the column collapsed (`true`) or expanded. + rail_iconic: Option, + /// In rail mode, the panel a click on its icon brought to the front this pass. + front: Option

, } /// Where the flyout of one cell shows: the group with the cell's panel active, its top left, its size, whether the @@ -245,6 +274,7 @@ impl<'a, P: Value + Hash + 'static> IconicColumn<'a, P> { opens: Side::End, bar: ColumnBar::Own, auto_collapse: false, + mode: IconicMode::Flyouts, within: Rect::NOTHING, open, view: None, @@ -255,6 +285,8 @@ impl<'a, P: Value + Hash + 'static> IconicColumn<'a, P> { laid: None, expand: false, flyout: None, + rail_iconic: None, + front: None, } .label(label) } @@ -283,7 +315,36 @@ impl<'a, P: Value + Hash + 'static> IconicColumn<'a, P> { self.show_at(ui, rect, |_, _| ()).output } - /// The panels of the column in order, each with its group. + /// Whether the column is a rail beside its expanded column: its chevron collapses the column. + fn expanded(&self) -> bool { + self.mode == IconicMode::Rail && !self.column.iconic + } + + /// Whether the cell `at`, of the panel `(group, panel)`, shows selected: the open flyout's, or in rail mode a + /// panel in front of the expanded column. + fn shows_selected(&self, at: usize, (group, panel): (usize, usize)) -> bool { + match self.mode { + IconicMode::Flyouts => self.shown == Some(at), + IconicMode::Rail => self.expanded() && self.column.groups.get(group).is_some_and(|group| group.active == panel), + } + } + + /// In rail mode, what a click on the cell `at` asks for: on a panel in front of the expanded column, the column + /// collapses; on any other, the column expands with that panel in front. + fn rail_click(&mut self, at: usize) { + let Some((group, panel)) = self.flat().get(at).copied() else { return }; + if self.shows_selected(at, (group, panel)) { + self.rail_iconic = Some(true); + return; + } + if self.column.iconic { + self.rail_iconic = Some(false); + } + if self.column.groups.get(group).is_some_and(|shown| shown.active != panel) { + self.front = self.panel(group, panel).cloned(); + } + } + /// The divider on the column's inner edge: the width runs from the rail to the width the column expands to. fn edge_divider(&self, rect: Rect, sizes: &DockSizes) -> Divider { let least = sizes.iconic_least; @@ -420,20 +481,23 @@ impl Component for IconicColumn<'_, P> { self.bar_rect = plan.bar; if self.bar == ColumnBar::Own { let (chevron, _) = bar_slots(plan.bar, self.edge, cx.flow.is_rtl()); - let name = ColumnArrow::Collapse.name(&cx.words::(), false); + let name = ColumnArrow::Collapse.name(&cx.words::(), self.expanded()); let _ = cx.header_part(chevron_edge(self.edge), CHEVRON, chevron).sense(Sense::CLICK | Sense::FOCUS).focusable().tooltip(name); } for (at, (_, _, cell)) in plan.cells.iter().enumerate() { let Some(panel) = self.flat().get(at).and_then(|(group, panel)| self.panel(*group, *panel)) else { continue }; let label = (self.spec)(panel).label; - cx.part(CELL.at(at as u64), *cell) - .sense(Sense::CLICK | Sense::DRAG | Sense::TAKE_FOCUS) - .focusable() - .tooltip(label) - .toggles_at("flyout", at) - .on_click(); + // A rail's icons expand and collapse the column, which `update` reads from their activation. + let rail = self.mode == IconicMode::Rail; + let part = cx.part(CELL.at(at as u64), *cell).sense(Sense::CLICK | Sense::DRAG | Sense::TAKE_FOCUS).focusable().tooltip(label); + if !rail { + part.toggles_at("flyout", at).on_click(); + } if let Some(name) = plan.names.get(at) { - cx.part(NAME.at(at as u64), *name).sense(Sense::CLICK | Sense::DRAG).keyboard_via(CELL).toggles_at("flyout", at).on_click(); + let part = cx.part(NAME.at(at as u64), *name).sense(Sense::CLICK | Sense::DRAG).keyboard_via(CELL); + if !rail { + part.toggles_at("flyout", at).on_click(); + } } } for (group, grip) in &plan.grips { @@ -485,6 +549,16 @@ impl Component for IconicColumn<'_, P> { if let Some((_, coord)) = divider::keys(cx, EDGE, &[(0, edge)], sizes.column.step, sizes.column.jump) { self.move_edge(rect, &edge, coord); } + if self.mode == IconicMode::Rail { + for at in 0..flat.len() { + if !began && (cx.part_activated(CELL.at(at as u64)).is_some() || cx.part_activated(NAME.at(at as u64)).is_some()) { + self.rail_click(at); + } + } + self.register(&ctx, rect, rtl, &plan, &sizes); + self.laid = Some(plan); + return; + } let handles: Vec<_> = (0..flat.len()).map(|at| popup.at(at)).collect(); // A toggle of an icon (click, Enter, Alt+Down) changed a popup this pass: the user chose. Otherwise the // bound value is the truth and the popups follow it. @@ -526,14 +600,14 @@ impl Component for IconicColumn<'_, P> { ui.draw().surface(cx.rect, SurfaceKind::Panel, Corners::All); if self.bar == ColumnBar::Own { ui.draw().surface(self.bar_rect, SurfaceKind::Background, Corners::None); - paint_chevron(ui, self.edge, ColumnArrow::Collapse, false, cx.flow.is_rtl(), &cx.words::()); + paint_chevron(ui, self.edge, ColumnArrow::Collapse, self.expanded(), cx.flow.is_rtl(), &cx.words::()); } let flat = self.flat(); - for (at, (group, panel)) in flat.iter().enumerate() { - let Some(panel) = self.panel(*group, *panel) else { continue }; + for (at, &cell) in flat.iter().enumerate() { + let Some(panel) = self.panel(cell.0, cell.1) else { continue }; let spec = (self.spec)(panel); let icon: IconSpec<'static> = spec.icon.unwrap_or_else(|| IconSpec::initial(spec.label.as_str())); - let selected = self.shown == Some(at); + let selected = self.shows_selected(at, cell); if let Some(name) = self.laid.as_ref().and_then(|plan| plan.names.get(at)) { let style = &cx.style; let room = if cx.flow.is_rtl() { name.with_max_x(name.max.x - style.name_gap) } else { name.with_min_x(name.min.x + style.name_gap) }; @@ -571,13 +645,16 @@ impl Component for IconicColumn<'_, P> { } divider::describe(access, EDGE, 0, &self.edge_divider(cx.rect, &sizes.column), words.resize.as_str(), sizes.column.step); if self.bar == ColumnBar::Own { - describe_chevron(access, &ColumnArrow::Collapse.name(&words, false)); + describe_chevron(access, &ColumnArrow::Collapse.name(&words, self.expanded())); } } /// The flyout of every cell whose popup is open, beside the column on the side it opens on. A resize the user makes /// comes back as the open group's new size and, when its top moved, its top's offset from the group's icons. fn overlay(&mut self, ui: &mut OverlayUi<'_>, cx: &mut Cx<'_, Self>) { + if self.mode == IconicMode::Rail { + return; + } let popup = cx.popup("flyout"); let sizes = cx.style.sizes.column; let (opens, auto_collapse, column) = (self.opens, self.auto_collapse, cx.rect); @@ -630,8 +707,17 @@ impl Component for IconicColumn<'_, P> { } fn finish(self, cx: Cx<'_, Self>) -> IconicColumnOutput

{ - let iconic = self.record.iconic.or(self.expand.then_some(false)); - IconicColumnOutput { edit: cx.edit_response(), placed: cx.rect, iconic, picked: self.record.picked, width: self.width, flyout: self.flyout } + // The chevron expands a collapsed column, and collapses the expanded one a rail stands beside. + let iconic = self.record.iconic.or(self.expand.then_some(self.expanded())).or(self.rail_iconic); + IconicColumnOutput { + edit: cx.edit_response(), + placed: cx.rect, + iconic, + front: self.front, + picked: self.record.picked, + width: self.width, + flyout: self.flyout, + } } } @@ -709,7 +795,7 @@ impl Container for IconicColumn<'_, P> { } if let Some(grip) = column_grip(self.column, self.spec, cx) { let band = bar_band(ui, self.bar_rect, self.edge); - self.record = show_bar(ui, cx, band, false, self.auto_collapse, ColumnArrow::Collapse, grip.icons(true)); + self.record = show_bar(ui, cx, band, self.expanded(), self.auto_collapse, ColumnArrow::Collapse, grip.icons(true)); } } } diff --git a/crates/ui-panels/src/docking/iconic/stories.rs b/crates/ui-panels/src/docking/iconic/stories.rs index e9e46f73f..de1ec143c 100644 --- a/crates/ui-panels/src/docking/iconic/stories.rs +++ b/crates/ui-panels/src/docking/iconic/stories.rs @@ -4,7 +4,7 @@ use super::CELL; use crate::buttons::Button; use crate::contract::ShowContainer as _; use crate::contract::{Bind, BodyCx, Show as _, Validity}; -use crate::docking::{ColumnBar, GroupAt, IconicColumn, IconicColumnOutput, PanelSpec}; +use crate::docking::{ColumnBar, GroupAt, IconicColumn, IconicColumnOutput, IconicMode, PanelSpec}; use crate::runtime::commands::{CommandInput, CommandState}; use crate::runtime::env::{Env, Message}; use crate::sections::Panel; @@ -111,6 +111,15 @@ fn icons_in_a_floating_window(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { .into() } +/// The icons as a rail ([`IconicMode::Rail`]) beside their expanded column: the panels in front of their groups +/// show selected, and the bar's chevron collapses the column. A click opens no flyout. +#[story(IconicColumn<'static, u8>, covers = [Default], drive = Drive::Never)] +fn icons_as_a_rail_beside_the_expanded_column(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { + let column = Column::new(vec![Group::new(vec![0, 1], 1), Group::new(vec![2], 0)]); + let column = IconicColumn::new("Panels", global("iconic column", "rail story"), &column, Bind::kept(), &spec).mode(IconicMode::Rail); + at_stage(ui, column, |_, _, _, _| None).into() +} + /// A click on the first icon opens the flyout of its panel, which the bound value then names. fn open_first_flyout(fixture: &mut Fixture) { let Some(id) = fixture.root_id() else { return }; diff --git a/crates/ui-panels/src/docking/mod.rs b/crates/ui-panels/src/docking/mod.rs index 145a456d9..e67f94a75 100644 --- a/crates/ui-panels/src/docking/mod.rs +++ b/crates/ui-panels/src/docking/mod.rs @@ -60,7 +60,7 @@ pub use dock_column::{ stepped, width_bounds, }; pub use flyout::{Flyout, FlyoutOutput, FlyoutShown, FlyoutStyle, GroupAt}; -pub use iconic::{FlyoutResize, IconicColumn, IconicColumnOutput, IconicColumnStyle, IconicSizes}; +pub use iconic::{FlyoutResize, IconicColumn, IconicColumnOutput, IconicColumnStyle, IconicMode, IconicSizes}; pub use window_menu::{WindowMenuRows, WindowMenuRowsOutput}; use crate::contract::{ diff --git a/crates/ui-panels/src/docking/panels.rs b/crates/ui-panels/src/docking/panels.rs index 1e17eb818..dc46deaea 100644 --- a/crates/ui-panels/src/docking/panels.rs +++ b/crates/ui-panels/src/docking/panels.rs @@ -14,7 +14,8 @@ use egui::{Context, Id, Ui}; /// itself: the dock shows no tab strip and no panel body for that group, and calls neither `group_header` nor `body` /// for it. A flyout measures its group before it shows it, so a host view runs at `GroupAt::Measure` too. /// 2. Otherwise `group_header` once, inside the group's header region before its tab strip, then `spec` for each of -/// its panels, then `body` for the panels whose bodies are shown. `panel_rows` runs when a panel's menu opens. +/// its panels, then `body` for the panels whose bodies are shown, and `footer` under the body of a shown panel +/// whose spec has `PanelSpec::footer`. `panel_rows` runs when a panel's menu opens. /// /// A panel's `spec` is read every pass, so a host may change a label or a limit between passes. The dock's actions /// name a group by one of its panels. @@ -34,6 +35,11 @@ pub trait DockPanels

{ /// (`PanelSpec::window_kind` `Document`) gets the group's body edge to edge. fn body(&mut self, panel: &P, ui: &mut Ui, cx: &mut BodyCx<'_>); + /// Shows `panel`'s footer in `ui`: a footer bar pinned under the body, across the group, that stays in view while + /// the body scrolls (a panel's actions on everything its body lists). The dock calls it only for a panel whose + /// spec has `PanelSpec::footer` (the default shows nothing). + fn footer(&mut self, _panel: &P, _ui: &mut Ui, _cx: &mut BodyCx<'_>) {} + /// The version of the app data `panel`'s body shows that the framework does not track (a document's revision, a /// job's progress). With one, the body settles (`Lazy::settles` with `Lazy::content`): it runs only when its /// version, its room or something the framework tracks in it changed, the pointer is over it or focus is in it, and diff --git a/crates/ui-panels/src/docking/spec.rs b/crates/ui-panels/src/docking/spec.rs index 11b24993c..86f9c2ecf 100644 --- a/crates/ui-panels/src/docking/spec.rs +++ b/crates/ui-panels/src/docking/spec.rs @@ -134,6 +134,9 @@ pub struct PanelSpec { /// The panel's toggle command: an iconic cell's face is `IconButton::command` of it, so the marker and the hint /// follow the command. pub command: Option, + /// The panel has a footer pinned under its body, which `DockPanels::footer` fills: it stays in view while the + /// body scrolls. + pub footer: bool, } impl PanelSpec { @@ -150,9 +153,17 @@ impl PanelSpec { canvas: false, grid: None, command: None, + footer: false, } } + /// The panel has a footer pinned under its body, which `DockPanels::footer` fills. + #[must_use] + pub fn footer(mut self) -> Self { + self.footer = true; + self + } + /// The panel's toggle command. #[must_use] pub fn command(mut self, command: impl Into) -> Self { diff --git a/crates/ui-panels/src/docking/stories.rs b/crates/ui-panels/src/docking/stories.rs index 9e08e6d01..7b211b99b 100644 --- a/crates/ui-panels/src/docking/stories.rs +++ b/crates/ui-panels/src/docking/stories.rs @@ -5,6 +5,7 @@ use super::group::MENU; use super::stack::{StackSection, StackSections}; use super::tree::FrameRules; use super::{DockCommands, DockGroup, DockPanels, DragUnit, GroupGrip, HANDLE, PanelKey, PanelSpec, PanelTitle, SplitArea, Splitter, WindowMenuRows}; +use crate::buttons::Button; use crate::contract::SizeLimits; use crate::contract::{Bind, BodyCx, Props as _, Show as _, ShowContainer as _, Validity}; use crate::menu::{Menu, PanelRow}; @@ -94,6 +95,19 @@ fn a_group_in_a_window(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { DockGroup::new(LAYERS, &panels, panels[0].key).in_window().show(ui, |_, _| ()).output.into() } +/// A group whose panel has a footer of actions pinned under its body, which stays in view while the body scrolls. +#[story(DockGroup<'static, usize>, covers = [Default])] +fn a_group_with_a_footer(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { + let panels = titles(&[LAYERS, CHANNELS]); + DockGroup::new(LAYERS, &panels, panels[0].key) + .footer(|ui, _| { + Button::new("Apply All").show(ui); + }) + .show(ui, |_, _| ()) + .output + .into() +} + /// A click on the panel menu button opens the group's panel menu. fn open_panel_menu(fixture: &mut Fixture) { if let Some(button) = fixture.root_id().and_then(|id| fixture.part(id, MENU)) { diff --git a/crates/ui-panels/src/docking/targets.rs b/crates/ui-panels/src/docking/targets.rs index 44a86f34f..3986623d8 100644 --- a/crates/ui-panels/src/docking/targets.rs +++ b/crates/ui-panels/src/docking/targets.rs @@ -131,13 +131,20 @@ impl DockSizes { /// The width of a column before the dock's room shrinks it. pub fn width

(&self, column: &Column

, spec: &dyn Fn(&P) -> PanelSpec) -> f32 { if column.iconic { - let (lo, hi) = self.shown_bounds(column, spec); - column.iconic_width.unwrap_or(lo).clamp(lo, hi) + self.iconic_width(column, spec) } else { self.expanded_width(column, spec) } } + /// The width of the icons of `column`, whether it is iconic or expanded beside a rail of its icons + /// ([`IconicMode::Rail`](super::IconicMode::Rail)): its iconic width from the rail width up to the width it + /// expands to. + pub fn iconic_width

(&self, column: &Column

, spec: &dyn Fn(&P) -> PanelSpec) -> f32 { + let (lo, hi) = (self.iconic_least, self.expanded_width(column, spec).max(self.iconic_least)); + column.iconic_width.unwrap_or(lo).clamp(lo, hi) + } + /// The actions that give the dock on `side` of `layout` the total width `total`, its columns scaled within /// their [`shown_bounds`](Self::shown_bounds) ([`scale_widths`]): [`Action::ResizeColumn`] for an expanded column, /// [`Action::ResizeIconic`] for an iconic one, which keeps its expanded width. A stepped column keeps its width, diff --git a/crates/ui-patterns/src/patterns/dock/area.rs b/crates/ui-patterns/src/patterns/dock/area.rs index e59c2d9ac..9a2029880 100644 --- a/crates/ui-patterns/src/patterns/dock/area.rs +++ b/crates/ui-patterns/src/patterns/dock/area.rs @@ -13,8 +13,8 @@ use crate::docking::{Arrangement, close_requests, cross_window, end_replaced_dra use crate::docking::{ ColumnArrow, ColumnBar, DockColumn, DockCommands, DockConfig, DockDropTarget, DockDropped, DockEvent, DockGroup, DockPanels, DockRoot, DockScene, DockSizes, DockSpot, DockTargets, DockTo, DockWords, DragUnit, FloatSpace, FloatingGroup, FlyoutResize, GroupAt, GroupDrag, HidePanels, - IconicColumn, IconicSizes, PanelDrag, PanelKey, PanelSpec, PanelTitle, SplitArea, WindowColumn, actions, dock_states, fit_widths, frame, - move_actions, stepped, + IconicColumn, IconicMode, IconicSizes, PanelDrag, PanelKey, PanelSpec, PanelTitle, SplitArea, WindowColumn, actions, dock_states, fit_widths, + frame, move_actions, stepped, }; use crate::menu::{GroupItem, MenuWords, PanelMenu, PanelRow}; use crate::runtime::commands::{CommandRef, CommandSet as _, Commands as _, focus_within}; @@ -254,6 +254,32 @@ impl Scene<'_, P> { fn panel(&self, key: PanelKey) -> Option<&P> { self.keys.get(&key) } + + /// Whether the docked `column` shows a rail of its icons beside it ([`IconicMode::Rail`]): an expanded column + /// that collapses to icons. + fn rail_beside(&self, column: &Column

) -> bool { + let spec = |panel: &P| self.spec(panel); + let collapses = column.panels().all(|panel| self.permissions(panel).collapses); + self.config.iconic_mode == IconicMode::Rail && !column.iconic && ColumnArrow::of(column, &spec, collapses) == ColumnArrow::Collapse + } + + /// The `(width, floor)` of each docked column of a dock, for [`fit_widths`]: a rail beside an expanded column adds + /// its width to both. + fn natural(&self, columns: &[Column

]) -> Vec<(f32, Option)> { + let spec = |panel: &P| self.spec(panel); + let natural = self.sizes.natural(columns, &spec); + columns + .iter() + .zip(natural) + .map(|(column, (width, floor))| { + if !self.rail_beside(column) { + return (width, floor); + } + let rail = self.sizes.iconic_width(column, &spec); + (width + rail, floor.map(|floor| floor + rail)) + }) + .collect() + } } /// What the area reports from one pass. @@ -541,9 +567,8 @@ fn show_area( dock: id, }; - let spec_of = |panel: &P| scene.spec(panel); let limits = |panel: &P| scene.spec(panel).limits; - let dock_width = |columns: &[Column

]| scene.sizes.natural(columns, &spec_of).iter().map(|(width, _)| *width).sum::(); + let dock_width = |columns: &[Column

]| scene.natural(columns).iter().map(|(width, _)| *width).sum::(); let stripless = |panel: &P| scene.spec(panel).canvas; let rules = FrameRules::new(&limits).dock_width(&dock_width).stripless(&stripless); let label = Label::from(body.words::().panels.as_str().to_owned()); @@ -833,11 +858,15 @@ impl Pass<'_, P> { if look.in_window { group = group.in_window(); } + let spec = scene.spec(&members[at]); if minimized { group = group.minimized(); - } else if !document(&scene.spec(&members[at])) { + } else if !document(&spec) { group = group.pad(Pad::Regular); } + if spec.footer { + group = group.footer(move |ui, body| panels.borrow_mut().footer(&members[at], ui, body)); + } if scene.config.tab_close_buttons { group = group.closable(); } @@ -918,8 +947,7 @@ impl Pass<'_, P> { /// The columns of a dock, from the window edge inwards. fn dock(&mut self, ui: &mut Ui, body: &mut BodyCx<'_>, plan: DockPlan<'_, P>) { let scene = self.scene; - let spec = |panel: &P| scene.spec(panel); - let widths = fit_widths(&scene.sizes.natural(plan.columns, &spec), plan.rect.width()); + let widths = fit_widths(&scene.natural(plan.columns), plan.rect.width()); let reading = plan.flow.to_physical(plan.rect); let start = plan.edge == DockEdge::Start; let mut cursor = if start { reading.left() } else { reading.right() }; @@ -982,20 +1010,45 @@ impl Pass<'_, P> { let spec = |panel: &P| scene.spec(panel); let name = Label::from(body.words::().panels.as_str().to_owned()); let dock = self.dock; - let ColumnAt { cell, edge, bar, within, open } = at; + let ColumnAt { mut cell, edge, bar, within, open } = at; let in_window = bar == ColumnBar::Window; let opens = if edge == DockEdge::Start { Side::End } else { Side::Start }; - let work = if column.iconic { - let output = IconicColumn::new(name, dock, column, Bind::given(open), &spec) + // Only a docked column's icons are a rail; a floating window's open flyouts. + let mode = if in_window { IconicMode::Flyouts } else { scene.config.iconic_mode }; + let mut icons = |cell: Rect, open: Option

| { + IconicColumn::new(name.clone(), dock, column, Bind::given(open), &spec) .edge(edge) .opens(opens) .bar(bar) .within(within) .auto_collapse(scene.auto_collapse) - .show_flyouts_at(ui, cell, |group, at, ui, body| self.group_of(ui, body, group, at, in_window)); + .mode(mode) + .show_flyouts_at(ui, cell, |group, at, ui, body| self.group_of(ui, body, group, at, in_window)) + }; + let work = if column.iconic { + let output = icons(cell, open); self.report.flyout.extend(output.edit.events); + self.rail_work(output.front); ColumnWork { iconic: output.iconic, picked: output.picked, resized: Vec::new(), width: output.width, flyout: output.flyout } } else { + if !in_window && scene.rail_beside(column) { + // The rail keeps to the dock's window edge and the expanded column shows inward of it. + let rail = scene.sizes.iconic_width(column, &spec).min(cell.width()); + let at_left = (edge == DockEdge::Start) != scene.rtl; + let (rail_cell, rest) = if at_left { + (cell.with_max_x(cell.left() + rail), cell.with_min_x(cell.left() + rail)) + } else { + (cell.with_min_x(cell.right() - rail), cell.with_max_x(cell.right() - rail)) + }; + cell = rest; + let output = icons(rail_cell, None); + self.rail_work(output.front); + // The rail's inner edge sets its own width, not the expanded column's. + self.column_work(column, ColumnWork { iconic: output.iconic, picked: output.picked, resized: Vec::new(), width: None, flyout: None }); + if let (Some(width), Some(first)) = (output.width, column.groups.first().and_then(|group| group.panels.first())) { + self.report.actions.push(Action::resize_iconic(first.clone(), Some(width))); + } + } let output = DockColumn::new(name, dock, column, &spec) .edge(edge) .bar(bar) @@ -1010,6 +1063,11 @@ impl Pass<'_, P> { self.column_work(column, work); } + /// Brings the panel a click on its rail icon chose, `front`, to the front of its group. + fn rail_work(&mut self, front: Option

) { + self.report.actions.extend(front.map(Action::activate)); + } + /// Turns what a column reported into actions and drags. fn column_work(&mut self, column: &Column

, work: ColumnWork

) { let Some(first) = column.groups.first().and_then(|group| group.panels.first()) else { return }; diff --git a/crates/ui-patterns/tests/it/docking/columns.rs b/crates/ui-patterns/tests/it/docking/columns.rs index d335a4bd6..7d5b05f4a 100644 --- a/crates/ui-patterns/tests/it/docking/columns.rs +++ b/crates/ui-patterns/tests/it/docking/columns.rs @@ -4,7 +4,7 @@ use craft_behavior::Axis; use craft_behavior::dock::{Action, Column, DockEdge, Floating, Group, Layout, Node, Permissions, SplitSize, Workspace, node_at}; use craft_ui::contract::{Bind, BodyCx, Role, Show as _, SizeLimits}; use craft_ui::display::Text; -use craft_ui::docking::{DockConfig, DockGrid, DockHeights, DockPanels, GroupSize, PanelSpec, group_heights}; +use craft_ui::docking::{DockConfig, DockGrid, DockHeights, DockPanels, GroupSize, IconicMode, PanelSpec, group_heights}; use craft_ui::patterns::dock::DockArea; use craft_ui::testing::{Fixture, trial}; use egui::{Pos2, Rect, Ui, Vec2}; @@ -244,3 +244,71 @@ fn a_floating_stepped_windows_left_and_top_edge_drags_keep_the_opposite_edge() { let after = shown_tools(&fixture); assert!((after.bottom() - before.bottom()).abs() <= 1.5, "the bottom edge stays: {before:?}, then {after:?}"); } + +/// Two side panels in one group, named and with a line of content each. +struct Sides; + +impl DockPanels for Sides { + fn spec(&self, panel: &u32) -> PanelSpec { + PanelSpec::new(match panel { + 10 => "Alpha", + 11 => "Beta", + _ => "Canvas", + }) + } + + fn body(&mut self, panel: &u32, ui: &mut Ui, _: &mut BodyCx<'_>) { + match panel { + 10 => Text::new("Alpha body").show(ui), + 11 => Text::new("Beta body").show(ui), + _ => return, + }; + } +} + +/// With the rail mode, a click on an icon expands its column with that panel in front, and the icons stay beside +/// it, between the panel and the window edge; a click on another icon switches the panel, and a click on the icon of +/// the panel in front collapses the column again. +#[trial] +fn rail_icons_stay_beside_the_expanded_column_and_the_open_panels_icon_collapses_it() { + let side = Column::new(vec![Group::new(vec![10, 11], 0)]).with_iconic(true); + let root = Node::split(Axis::X, SplitSize::Ratio(0.6), Node::tabs(vec![1], 0), Node::dock(DockEdge::End, vec![side])); + let workspace = Rc::new(RefCell::new(Workspace::new(Layout::new(Some(root), Vec::new())))); + let held = Rc::clone(&workspace); + let mut fixture = Fixture::new(move |ui| { + let mut workspace = held.borrow().clone(); + let config = DockConfig::default().iconic_mode(IconicMode::Rail); + let out = DockArea::new("Rail dock", Bind::given(workspace.clone()), &mut Sides, config).show(ui); + for action in out.actions { + drop(workspace.apply(action, false, |_: &u32| Permissions::ALL)); + } + *held.borrow_mut() = workspace; + }); + fixture.room(Vec2::new(900.0, 500.0)).settle(); + let icon = |fixture: &Fixture, name: &str| { + let tree = fixture.tree(); + fixture + .by_role(Role::BUTTON) + .into_iter() + .find(|button| craft_ui::testing::access::name(tree, button.node) == Some(name)) + .unwrap_or_else(|| panic!("the rail shows the {name} icon")) + }; + let iconic = || end_columns(&workspace.borrow().layout)[0].iconic; + let shown = |fixture: &Fixture, text: &str| fixture.texts().iter().any(|run| run.text == text); + + let beta = icon(&fixture, "Beta"); + fixture.click(&beta).settle(); + assert!(!iconic(), "a click on an icon expands the column"); + assert!(shown(&fixture, "Beta body") && !shown(&fixture, "Alpha body"), "the clicked panel is in front"); + let (beta, body) = (icon(&fixture, "Beta"), fixture.by_label("Beta body").expect("the panel's content").rect); + assert!(body.right() <= beta.rect.left(), "the icons stay beside the panel, at the window edge: {body:?}, icon {:?}", beta.rect); + + let alpha = icon(&fixture, "Alpha"); + fixture.click(&alpha).settle(); + assert!(!iconic() && shown(&fixture, "Alpha body") && !shown(&fixture, "Beta body"), "another icon switches the panel in front"); + + let alpha = icon(&fixture, "Alpha"); + fixture.click(&alpha).settle(); + assert!(iconic(), "the icon of the panel in front collapses the column"); + assert!(!shown(&fixture, "Alpha body"), "and its panel no longer shows"); +} diff --git a/crates/ui-patterns/tests/it/docking/group_view.rs b/crates/ui-patterns/tests/it/docking/group_view.rs index a92f50c55..8589689ed 100644 --- a/crates/ui-patterns/tests/it/docking/group_view.rs +++ b/crates/ui-patterns/tests/it/docking/group_view.rs @@ -2,10 +2,13 @@ use craft_behavior::Axis; use craft_behavior::dock::{Layout, Node, SplitSize, Workspace}; -use craft_ui::contract::{Bind, BodyCx}; +use craft_ui::buttons::Button; +use craft_ui::contract::{Bind, BodyCx, Scroll, Show as _, ShowContainer as _}; +use craft_ui::layout_components::Stack; +use craft_ui::display::Text; use craft_ui::docking::{DockConfig, DockPanels, GroupAt, PanelSpec}; use craft_ui::patterns::dock::DockArea; -use craft_ui::testing::{Fixture, trial}; +use craft_ui::testing::{Fixture, pointer, trial}; use egui::{Rect, Ui, Vec2}; use std::cell::Cell; use std::rc::Rc; @@ -52,3 +55,46 @@ fn a_group_view_lays_out_and_clips_to_its_group_rect() { assert!(rect.contains_rect(room), "the view's room {room:?} lies in its group's rect {rect:?}"); assert!(rect.contains_rect(clip), "the view's clip {clip:?} lies in its group's rect {rect:?}"); } + +/// A panel whose body lists more rows than its group shows, with a footer of one action. +struct Listed; + +impl DockPanels for Listed { + fn spec(&self, _: &usize) -> PanelSpec { + PanelSpec::new("Findings").footer() + } + + fn body(&mut self, _: &usize, ui: &mut Ui, _: &mut BodyCx<'_>) { + Stack::new().fill().scroll(Scroll::vertical()).show(ui, |ui, _| { + for row in 0..60 { + Text::new(format!("Row {row}")).show(ui); + } + }); + } + + fn footer(&mut self, _: &usize, ui: &mut Ui, _: &mut BodyCx<'_>) { + Button::new("Apply all").show(ui); + } +} + +/// A panel's footer is pinned under its body: it shows inside the group while the body is taller than the group, and +/// stays where it is when the body scrolls. +#[trial] +fn a_panels_footer_stays_in_view_under_a_scrolling_body() { + let workspace = Workspace::new(Layout::new(Some(Node::tabs(vec![1], 0)), Vec::new())); + let mut fixture = Fixture::new(move |ui| { + DockArea::new("Dock", Bind::given(workspace.clone()), &mut Listed, DockConfig::default()).show(ui); + }); + let room = Vec2::new(400.0, 300.0); + fixture.room(room).settle(); + let footer = fixture.by_label("Apply all").expect("the footer shows its action").rect; + assert!(footer.bottom() <= room.y, "the footer lies inside the group: {footer:?}"); + let row = |fixture: &Fixture| fixture.by_label("Row 0").expect("the first row").rect; + let before = row(&fixture); + assert!(before.bottom() <= footer.top(), "the body lies above the footer: {before:?}, footer {footer:?}"); + + fixture.frame(vec![egui::Event::PointerMoved(before.center())]); + fixture.frame(vec![pointer::wheel(-120.0)]).settle(); + assert!(row(&fixture).top() < before.top(), "the body scrolls: {before:?}, then {:?}", row(&fixture)); + assert_eq!(fixture.by_label("Apply all").map(|action| action.rect), Some(footer), "the footer stays where it was"); +} diff --git a/crates/ui-widgets/src/list/findings.rs b/crates/ui-widgets/src/list/findings.rs index b790fdd90..149f23988 100644 --- a/crates/ui-widgets/src/list/findings.rs +++ b/crates/ui-widgets/src/list/findings.rs @@ -155,6 +155,7 @@ pub struct FindingsList<'a> { common: Common, #[container] props: ContainerProps, + #[collection] items: CollectionProps, /// The selection the caller owns. #[prop] diff --git a/crates/ui-widgets/src/tabs/rules.rs b/crates/ui-widgets/src/tabs/rules.rs index 7c36a791e..83cfb5eb5 100644 --- a/crates/ui-widgets/src/tabs/rules.rs +++ b/crates/ui-widgets/src/tabs/rules.rs @@ -99,6 +99,12 @@ impl TabKind { self == Self::Document } + /// Whether only a primary press shows a tab: a secondary click on a document tab opens its menu and a middle click + /// closes it, and neither shows it. + pub const fn primary_shows(self) -> bool { + matches!(self, Self::Document) + } + /// Whether a drag resting over an unselected tab selects it. pub const fn selects_under_drag(self) -> bool { matches!(self, Self::Document) diff --git a/crates/ui-widgets/src/tabs/strip.rs b/crates/ui-widgets/src/tabs/strip.rs index 0d7ef1981..c8f58d058 100644 --- a/crates/ui-widgets/src/tabs/strip.rs +++ b/crates/ui-widgets/src/tabs/strip.rs @@ -311,7 +311,7 @@ impl<'a, K: Clone + Eq + Hash + Send + Sync + std::fmt::Debug + 'static> TabStri #[must_use] pub fn kind(mut self, kind: TabKind) -> Self { self.kind = kind; - self.items = self.items.select_under_drag(kind.selects_under_drag()); + self.items = self.items.select_under_drag(kind.selects_under_drag()).primary_picks(kind.primary_shows()); self } @@ -325,7 +325,8 @@ impl<'a, K: Clone + Eq + Hash + Send + Sync + std::fmt::Debug + 'static> TabStri .pages(true) .arrows_select(false) .overflow(craft_behavior::Axis::X) - .select_under_drag(true), + .select_under_drag(TabKind::Document.selects_under_drag()) + .primary_picks(TabKind::Document.primary_shows()), kind: TabKind::Document, large: false, shown: None, diff --git a/crates/ui-widgets/tests/it/list.rs b/crates/ui-widgets/tests/it/list.rs index 4b75004fd..cb084eb53 100644 --- a/crates/ui-widgets/tests/it/list.rs +++ b/crates/ui-widgets/tests/it/list.rs @@ -217,6 +217,24 @@ fn a_click_on_a_finding_activates_it() { assert!(seen.borrow().iter().any(|event| matches!(event, CollectionEvent::Activate(1))), "one click activates the finding"); } +/// A findings list given `max_rows` is as tall as that many rows, not the room it is offered, and scrolls the rest. +#[trial] +fn a_findings_list_with_max_rows_is_as_tall_as_those_rows() { + use craft_ui::contract::WordSetCx as _; + use craft_ui::list::{Finding, Findings, FindingsList, FindingsWords, Severity}; + let mut fixture = Fixture::new(move |ui| { + let findings: Vec = (0..20).map(|at| Finding::new(at, Severity::Warning, format!("Finding {at}"))).collect(); + let source = Findings::new(&findings); + FindingsList::new("Findings").max_rows(3).show_items(ui, &source, &mut |key, icx| findings[*key as usize].row(&icx.words::())); + }); + let room = Vec2::new(400.0, 500.0); + fixture.room(room).settle(); + let list = fixture.by_label("Findings").expect("the list").rect; + let row = fixture.by_label("Finding 0, Warning").expect("the first finding").rect; + assert!(list.height() >= 3.0 * row.height() - 0.5, "the list shows three rows: {list:?}, a row {row:?}"); + assert!(list.height() < 5.0 * row.height(), "the list is not as tall as the room: {list:?}, a row {row:?}"); +} + /// A list of the three rows built by `row`, in `room`, and what it reported. fn rows_rig(room: Vec2, row: fn(usize) -> ListRow<'static>) -> (Fixture, Events) { let seen = Rc::new(RefCell::new(Vec::new())); diff --git a/crates/ui-widgets/tests/it/tabs.rs b/crates/ui-widgets/tests/it/tabs.rs index d398282aa..bae2cd314 100644 --- a/crates/ui-widgets/tests/it/tabs.rs +++ b/crates/ui-widgets/tests/it/tabs.rs @@ -6,7 +6,7 @@ use craft_ui::contract::{CollectionEvent, Role, ShowCollection as _}; use craft_ui::runtime::egui::access::AccessTree; use craft_ui::tabs::{Tab, TabKind, TabStrip}; use craft_ui::testing::focus::AccessActionKind; -use craft_ui::testing::pointer::{moved, press, release}; +use craft_ui::testing::pointer::{moved, press, release, secondary}; use craft_ui::testing::{Fixture, Frames, trial}; use egui::{Key, Modifiers, Pos2, Rect, Ui}; use std::cell::{Cell, RefCell}; @@ -405,3 +405,34 @@ fn the_strip_reports_the_tab_under_the_pointer_while_another_root_holds_the_pres fixture.frame(vec![]); assert_eq!(*seen.borrow(), None, "the empty room has no tab"); } + +/// A secondary click on a document tab asks for the tab's menu without showing the tab. +#[trial] +fn a_secondary_click_on_a_document_tab_asks_for_its_menu_without_showing_it() { + let shown = Rc::new(Cell::new(0_usize)); + let menus = Rc::new(Cell::new(0_usize)); + let (now, asked) = (shown.clone(), menus.clone()); + let mut fixture = Fixture::new(move |ui| { + let keys = [0_usize, 1, 2]; + let source = keyed(&keys, |key: &usize| *key); + let out = TabStrip::new("Documents").shown(now.get()).show_items(ui, &source, &mut |key, _| Tab::new(TITLES[*key])); + for event in &out.response.events { + if let CollectionEvent::Selection(SelectionChange::Set(keys)) = event + && let Some(key) = keys.last() + { + now.set(*key); + } + } + if out.menu.is_some() { + asked.set(asked.get() + 1); + } + }); + fixture.settle(); + let two = tab_rect(fixture.tree(), "Two").center(); + fixture.frame(vec![moved(two)]); + fixture.frame(vec![secondary(two, true)]); + fixture.frame(vec![secondary(two, false)]); + fixture.settle(); + assert!(menus.get() > 0, "the secondary click asks for the tab's menu"); + assert_eq!(shown.get(), 0, "the secondary click does not show the tab"); +}