From dc4ba06687f6af96b2239128ba33d27bb0c4de33 Mon Sep 17 00:00:00 2001 From: aiongg Date: Fri, 20 Nov 2026 14:58:19 +0000 Subject: [PATCH] craft-ui-panels, craft-ui-patterns: HidePanels::Except holds a Tracked set of panel keys; the dock derives its pruned layout and each group's tab titles under revisions --- crates/ui-panels/src/docking/event.rs | 29 +++++++---- crates/ui-panels/src/docking/frame.rs | 10 +++- crates/ui-panels/src/docking/group.rs | 16 +++--- crates/ui-panels/src/docking/mod.rs | 35 ++++++++++++- crates/ui-panels/src/docking/placed.rs | 4 +- crates/ui-panels/src/docking/stories.rs | 10 ++-- crates/ui-panels/tests/it/dock_group.rs | 4 +- crates/ui-patterns/src/patterns/dock/area.rs | 52 +++++++++++++------ crates/ui-patterns/src/patterns/dock/hide.rs | 44 ++++++---------- .../tests/it/docking/drop_session.rs | 4 +- crates/ui-patterns/tests/it/docking/hidden.rs | 4 +- crates/ui-patterns/tests/it/docking/split.rs | 7 +-- 12 files changed, 140 insertions(+), 79 deletions(-) diff --git a/crates/ui-panels/src/docking/event.rs b/crates/ui-panels/src/docking/event.rs index 367fff306..34ff1f38f 100644 --- a/crates/ui-panels/src/docking/event.rs +++ b/crates/ui-panels/src/docking/event.rs @@ -1,6 +1,8 @@ //! `DockEvent`, `FloatSpace` and `HidePanels`: what a dock reports to the host and the host tells a dock. -use super::{DockCommands, DockSizes, DragUnit}; +use super::{DockCommands, DockSizes, DragUnit, PanelKey}; +use crate::contract::{MemoKey, MemoProps, Tracked}; +use std::collections::BTreeSet; use egui::{Rect, Vec2}; /// A request for host state outside the layout, or a report of where something ended up. @@ -42,24 +44,33 @@ pub enum DockEvent

{ /// Which panels the host hides. Protected panels always stay. While the shell hides the panels and keeps the tools /// (Shift+Tab), the panels `Except` names stay and every other panel hides; while it hides the dock (Tab), every panel /// hides. +/// +/// The set is a `Tracked` value, so a dock keys what it shows by the set's revision and keeps the pruned layout until +/// the set, the workspace or the shell's visibility changes. +#[derive(Clone, Copy)] #[non_exhaustive] -pub enum HidePanels<'a, P> { +pub enum HidePanels<'a> { /// Hides none. None, /// Hides every panel. All, - /// Every panel except those for which the function returns true. - Except(&'a dyn Fn(&P) -> bool), + /// Every panel except those whose [`PanelKey`] the set holds. + Except(&'a Tracked>), } -impl

Clone for HidePanels<'_, P> { - fn clone(&self) -> Self { - *self +impl MemoProps for HidePanels<'_> { + fn key(&self, key: &mut MemoKey) { + match self { + HidePanels::None => key.write_u32(0), + HidePanels::All => key.write_u32(1), + HidePanels::Except(keep) => { + key.write_u32(2); + keep.key(key); + } + } } } -impl

Copy for HidePanels<'_, P> {} - /// Where a docking command floats a panel, group or column when it gives no rect. A dock records one each pass; /// the host reads it to turn a command into placements. #[derive(Clone, Debug, PartialEq)] diff --git a/crates/ui-panels/src/docking/frame.rs b/crates/ui-panels/src/docking/frame.rs index e57718e4c..3c95ae5d4 100644 --- a/crates/ui-panels/src/docking/frame.rs +++ b/crates/ui-panels/src/docking/frame.rs @@ -1,6 +1,7 @@ //! What the tree adds around the groups: Maximize Frame, the hidden-panel prune and the outer edge bands. use super::config::DockConfig; +use super::PanelKey; use super::event::HidePanels; use super::targets::{DockSizes, DockSpot, DockTargets}; use super::tree; @@ -27,6 +28,11 @@ pub struct FrameView<'a, P: Clone> { } impl FrameView<'_, P> { + /// The view with its layout owned, to keep it past the layout it was made from. + pub fn into_owned(self) -> FrameView<'static, P> { + FrameView { layout: Cow::Owned(self.layout.into_owned()), maximized: self.maximized, hidden: self.hidden, paths: self.paths } + } + /// Writes the split sizes of `edited`, an edit of the view's layout, into `layout`, the layout the view was made /// from. Panels the view left out keep their place; only the docked tree's split sizes change: floating windows /// have no splits. @@ -64,13 +70,13 @@ fn split_sizes

(node: &Node

, paths: &HashMap, Vec>) -> Vec< pub fn maximize<'a, P: Clone + Eq + Hash>( layout: &'a Layout

, maximized: Option<&P>, - hide: HidePanels<'_, P>, + hide: HidePanels<'_>, protected: &dyn Fn(&P) -> bool, ) -> FrameView<'a, P> { let hidden = |panel: &P| match hide { HidePanels::None => false, HidePanels::All => !protected(panel), - HidePanels::Except(keep) => !protected(panel) && !keep(panel), + HidePanels::Except(keep) => !protected(panel) && !keep.contains(&PanelKey::of(panel)), }; // Only a docked panel maximizes its frame. let frame = maximized.and_then(|panel| match layout.place(panel)? { diff --git a/crates/ui-panels/src/docking/group.rs b/crates/ui-panels/src/docking/group.rs index ea0f215f2..16c7f8438 100644 --- a/crates/ui-panels/src/docking/group.rs +++ b/crates/ui-panels/src/docking/group.rs @@ -5,7 +5,7 @@ use super::commands::DockCommands; use super::drop::{self, DragUnit, start_group_drag}; use super::targets::{DockSizes, DockSpot, DockTargets, ZoneRule}; use super::words::DockWords; -use super::{PanelDrag, PanelKey, PanelTitle}; +use super::{PanelDrag, PanelKey, PanelTitle, Titles}; use crate::buttons::IconButton; use crate::contract::overlay::Anchor; use crate::contract::{ @@ -245,7 +245,7 @@ pub struct DockGroup<'a, P: Clone + Hash + Send + Sync + 'static> { #[container] props: ContainerProps, anchor: P, - panels: &'a [PanelTitle], + panels: Titles, active: PanelKey, /// Only the header shows; the body and its drop spots are left out. #[prop(flag)] @@ -292,10 +292,10 @@ pub struct DockGroup<'a, P: Clone + Hash + Send + Sync + 'static> { impl<'a, P: Clone + Hash + Send + Sync + PartialEq + Debug + 'static> DockGroup<'a, P> { /// The group named by `anchor` (one of its panels) with its `panels`, `active` showing. The group is named by the /// active panel's title. - pub fn new(anchor: P, panels: &'a [PanelTitle], active: PanelKey) -> Self { + pub fn new(anchor: P, panels: Titles, active: PanelKey) -> Self { let props = ContainerProps::new().sizing(Sizing::Fill).header(HeaderRegion::new().fill(SurfaceKind::Background)).command_scope(DockCommands::SCOPE); - let title = panels.iter().find(|panel| panel.key == active).map(|panel| panel.title.clone()).unwrap_or_default(); + let title = panels.as_slice().iter().find(|panel| panel.key == active).map(|panel| panel.title.clone()).unwrap_or_default(); DockGroup { common: Common::new(), props, @@ -445,7 +445,7 @@ impl Component for let Some(dock) = self.dock else { return }; let (rect, rtl, header) = (cx.rect, cx.flow.is_rtl(), cx.style.header); let strip = Rect::from_min_size(rect.min, Vec2::new(rect.width(), header)); - DockTargets::

::register(&cx.core.ctx, dock, DockSpot::tab(self.anchor.clone(), self.panels.len()), strip); + DockTargets::

::register(&cx.core.ctx, dock, DockSpot::tab(self.anchor.clone(), self.panels.as_slice().len()), strip); if self.minimized { return; } @@ -518,7 +518,7 @@ impl Container for } let row = TabRow { anchor: self.anchor.clone(), - panels: self.panels, + panels: self.panels.clone(), active: self.active, closable: self.closable, wheel_selects: self.wheel_selects_tabs, @@ -585,7 +585,7 @@ struct TabRow<'a, P> { /// The group's anchor panel, which names its drop spots. #[memo_props(hash = "a dock's panels are plain values it keys by their hash")] anchor: P, - panels: &'a [PanelTitle], + panels: Titles, active: PanelKey, closable: bool, wheel_selects: bool, @@ -598,7 +598,7 @@ fn tab_row(row: &mu let env = crate::runtime::env::Env::of(ui); let name = Label::from(env.words::().panels.as_str().to_owned()); let rtl = env.direction.is_rtl(); - let (panels, active, closable) = (row.panels, row.active, row.closable); + let (panels, active, closable) = (row.panels.as_slice(), row.active, row.closable); let from = PanelKey::of(&row.anchor); let drags = crate::runtime::drag::started(ui.ctx()); let source = keyed(panels, |panel: &PanelTitle| panel.key).with_text(|panel| Cow::Borrowed(panel.title.as_str())); diff --git a/crates/ui-panels/src/docking/mod.rs b/crates/ui-panels/src/docking/mod.rs index bf4e19204..45552a3f7 100644 --- a/crates/ui-panels/src/docking/mod.rs +++ b/crates/ui-panels/src/docking/mod.rs @@ -78,13 +78,14 @@ use craft_behavior::{Axis, EditEvents, Flow, Metrics, PartKey, Sense}; use divider::{Divider, Drag}; use egui::{Rect, Response, Vec2}; use std::fmt::Debug; +use std::sync::Arc; use std::hash::{DefaultHasher, Hash, Hasher}; use tree::{FrameRules, SplitHandle}; const HANDLE: PartKey = PartKey::new("handle"); /// The stable key of a panel. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, crate::contract::MemoProps)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, crate::contract::MemoProps, crate::contract::PlainData)] #[non_exhaustive] pub struct PanelKey(pub u64); @@ -114,6 +115,38 @@ pub struct PanelTitle { pub closable: bool, } +/// The tab titles of one group, with the key that stands for them in a memoized view's key. A host that keeps its +/// titles derived from revisions gives [`Titles::new`] the key it derived them under, so the key does not walk the +/// titles; [`Titles::from_content`] keys by the titles themselves. +#[derive(Clone, Debug)] +pub struct Titles { + list: Arc>, + key: u128, +} + +impl Titles { + /// The titles `list`, made from the inputs `key` follows: equal keys must mean equal titles. + pub fn new(key: &K, list: Arc>) -> Self { + Titles { list, key: crate::contract::MemoKey::of(key) } + } + + /// The titles `list`, keyed by their content: the key walks them. + pub fn from_content(list: Vec) -> Self { + Titles { key: crate::contract::MemoKey::of(&list), list: Arc::new(list) } + } + + /// The titles in tab order. + pub fn as_slice(&self) -> &[PanelTitle] { + &self.list + } +} + +impl crate::contract::MemoProps for Titles { + fn key(&self, key: &mut crate::contract::MemoKey) { + self.key.key(key); + } +} + impl PanelTitle { /// A panel `key` titled `title`, not closable from its tab. pub fn new(key: PanelKey, title: impl Into

, @@ -214,7 +215,7 @@ struct Drops<'a, P> { permissions: &'a dyn Fn(&P) -> Permissions, config: &'a DockConfig, specs: &'a HashMap, - hide: HidePanels<'a, P>, + hide: HidePanels<'a>, maximized: Option<&'a P>, rtl: bool, } @@ -254,9 +255,19 @@ struct Report

{ files: Vec, } +/// The inputs of the workspace's derived values: the workspace, the panels' specs and the lock. +#[derive(Clone, Copy, crate::contract::MemoProps)] +pub(super) struct ModelKey { + workspace: Revision, + specs: Revision, + locked: bool, +} + /// What every part of one pass reads. struct Scene<'s, P> { dock: Id, + /// The key the pruned layout was derived under: what every group's derived values follow. + view: u128, sizes: DockSizes, config: &'s DockConfig, layout: &'s Layout

, @@ -348,7 +359,7 @@ struct Look { /// What a group's header shows besides its panels' bodies: the tab titles, the panel menu's rows and whether the host /// gave any, and the panel commands' states. struct GroupParts { - titles: Vec, + titles: Titles, hosted: bool, states: Vec<(DockCommands, CommandState)>, } @@ -409,7 +420,8 @@ impl<'a, P: Clone + Eq + Hash + Debug + Send + Sync + 'static> DockArea<'a, P> { Some(Mixed::Same(held)) => held, _ => Arc::default(), }; - let model = derived(&ctx, id, &(held.revision(), specs.revision(), locked), || DockModel::of(&held, specs, locked)); + let key = ModelKey { workspace: held.revision(), specs: specs.revision(), locked }; + let model = derived(&ctx, id, &key, || DockModel::of(&held, specs, locked)); let error = model.error.clone(); let current = if error.is_none() { held } else { Arc::default() }; let rights = &model.rights; @@ -449,6 +461,7 @@ impl<'a, P: Clone + Eq + Hash + Debug + Send + Sync + 'static> DockArea<'a, P> { specs: &model.specs, keys: &model.keys, hide, + model: key, maximized: maximized.as_ref(), auto_collapse, sizes, @@ -549,7 +562,8 @@ struct Input<'i, P> { config: &'i DockConfig, specs: &'i HashMap, keys: &'i HashMap, - hide: HidePanels<'i, P>, + hide: HidePanels<'i>, + model: ModelKey, maximized: Option<&'i P>, auto_collapse: bool, sizes: DockSizes, @@ -578,16 +592,19 @@ fn show_area( panels: &mut dyn DockPanels

, mut flyout: Option<&mut Bind<'_, Option

>>, ) -> Passed

{ - let Input { id, ctx, current, config, specs, keys, hide, maximized, auto_collapse, sizes, rtl } = *input; + let Input { id, ctx, current, config, specs, keys, hide, model, maximized, auto_collapse, sizes, rtl } = *input; let shell = body.shell(); let mut memory = body.memory::>().clone(); let protected = |panel: &P| rights.get(panel).is_some_and(|rights| rights.is_protected()); - let Shown { view, floating } = hide::shown(current.layout(), maximized, hide, shell.as_ref(), &protected); + let (hide, floating) = hide::resolved(hide, shell.as_ref()); + let prune = PruneKey { model, hide, floating, maximized: maximized.map(PanelKey::of) }; + let view = derived(ctx, id.with("pruned"), &prune, || frame::maximize(current.layout(), maximized, hide, &protected).into_owned()); let layout: &Layout

= &view.layout; let bounds = shell.as_ref().map_or(body.rect, ShellCx::float_bounds); let space = float_space(bounds, &sizes, config, specs); let scene = Scene { dock: id, + view: MemoKey::of(&prune), sizes, config, layout, @@ -904,6 +921,7 @@ impl Pass<'_, P> { } let shown = &members[active]; let words = body.words::(); + let ctx = ui.ctx().clone(); let panels = RefCell::new(&mut *self.panels); // The tab titles, the menu rows and the panel commands' states, built when the group runs. // The tab titles, whether the host gives menu rows and the panel commands' states, built once per pass; the @@ -911,10 +929,14 @@ impl Pass<'_, P> { let parts: OnceCell = OnceCell::new(); let parts_of = || { parts.get_or_init(|| { - let titles = members - .iter() - .map(|panel| PanelTitle::new(PanelKey::of(panel), scene.spec(panel).label).closable(scene.permissions(panel).closable)) - .collect(); + let key = (scene.view, PanelKey::of(anchor)); + let list = derived(&ctx, scene.dock.with(("titles", key.1)), &key, || { + members + .iter() + .map(|panel| PanelTitle::new(PanelKey::of(panel), scene.spec(panel).label).closable(scene.permissions(panel).closable)) + .collect::>() + }); + let titles = Titles::new(&key, list); let hosted = !panels.borrow_mut().panel_rows(shown).is_empty(); let permissions = |panel: &P| scene.permissions(panel); let states = dock_states(&DockScene::new(scene.layout, scene.space, false, &permissions).floated(scene.floated), shown); @@ -926,7 +948,7 @@ impl Pass<'_, P> { let panels = &panels; let words = &words; let GroupParts { titles, hosted, states } = parts_of(); - let mut group = DockGroup::new(anchor.clone(), titles, PanelKey::of(&members[at])) + let mut group = DockGroup::new(anchor.clone(), titles.clone(), PanelKey::of(&members[at])) .extra(move |ui, body| panels.borrow_mut().group_header(members, at, ui, body)) .dock(self.dock) .zones(scene.config.zone_rule()) diff --git a/crates/ui-patterns/src/patterns/dock/hide.rs b/crates/ui-patterns/src/patterns/dock/hide.rs index 7ea931261..944613d3b 100644 --- a/crates/ui-patterns/src/patterns/dock/hide.rs +++ b/crates/ui-patterns/src/patterns/dock/hide.rs @@ -1,39 +1,27 @@ //! The hidden-panel prune of a dock area: what the host hides, the shell's panel visibility and Maximize Frame -//! decide which panels the area shows. +//! decide which panels the area shows. The area derives the pruned layout under a [`PruneKey`] and keeps it while the +//! key holds. -use crate::docking::HidePanels; -use crate::docking::frame::{FrameView, maximize}; +use super::area::ModelKey; +use crate::docking::{HidePanels, PanelKey}; use crate::runtime::env::ShellCx; -use craft_behavior::dock::Layout; -use std::hash::Hash; -/// The layout as the area shows it, and whether its floating windows show. -pub(super) struct Shown<'a, P: Clone> { - /// The pruned layout with its write-back map. - pub(super) view: FrameView<'a, P>, - /// Floating windows show: the shell shows them, or it hides the panels and the view keeps what the host names. +/// What the pruned layout is a function of: the workspace, the specs and the lock (the protected panels), what is +/// hidden after the shell's visibility, whether floating windows show and the maximized panel. +#[derive(crate::contract::MemoProps)] +pub(super) struct PruneKey<'h> { + pub(super) model: ModelKey, + pub(super) hide: HidePanels<'h>, pub(super) floating: bool, -} - -/// `layout` with the host's `hide`, the shell's panel visibility and the frame of `maximized` applied. Protected -/// panels always stay, so a canvas shows while the dock is hidden. While the shell hides the panels and keeps the -/// tools (Shift+Tab), the panels the host's `HidePanels::Except` names stay, docked or floating, and every other panel -/// hides; while the shell hides the dock (Tab, body-only mode), every panel hides. Size edits made on the view go back -/// through `FrameView::write_back`. -pub(super) fn shown<'a, P: Clone + Eq + Hash>( - layout: &'a Layout

, - maximized: Option<&P>, - hide: HidePanels<'_, P>, - shell: Option<&ShellCx>, - protected: &dyn Fn(&P) -> bool, -) -> Shown<'a, P> { - let (hide, floating) = resolved(hide, shell); - Shown { view: maximize(layout, maximized, hide, protected), floating } + pub(super) maximized: Option, } /// The panels the area hides, the host's `hide` with the shell's panel visibility applied, and whether floating windows -/// show (see [`shown`]). -pub(super) fn resolved<'h, P>(hide: HidePanels<'h, P>, shell: Option<&ShellCx>) -> (HidePanels<'h, P>, bool) { +/// show. Protected panels always stay, so a canvas shows while the dock is hidden. While the shell hides the panels and +/// keeps the tools (Shift+Tab), the panels the host's `HidePanels::Except` names stay, docked or floating, and every +/// other panel hides; while the shell hides the dock (Tab, body-only mode), every panel hides. Size edits made on the +/// pruned view go back through `FrameView::write_back`. +pub(super) fn resolved<'h>(hide: HidePanels<'h>, shell: Option<&ShellCx>) -> (HidePanels<'h>, bool) { match shell { None => (hide, true), Some(shell) if shell.panels_hidden() => (if let HidePanels::Except(keep) = hide { HidePanels::Except(keep) } else { HidePanels::All }, true), diff --git a/crates/ui-patterns/tests/it/docking/drop_session.rs b/crates/ui-patterns/tests/it/docking/drop_session.rs index 21677b6d8..80c1a314a 100644 --- a/crates/ui-patterns/tests/it/docking/drop_session.rs +++ b/crates/ui-patterns/tests/it/docking/drop_session.rs @@ -6,7 +6,7 @@ use craft_behavior::dock::{Layout, Node, Permissions, SplitSize}; use craft_ui::contract::SizeLimits; use craft_ui::contract::{Bind, Common, Component, Cx, MeasureCx, Pointer as _, Role, Show as _, ShowContainer as _}; use craft_ui::docking::tree::{self, FrameRules}; -use craft_ui::docking::{DockDropTarget, DockDropped, DockGroup, DockSizes, GroupDrag, PanelDrag, PanelKey, PanelTitle, SplitArea}; +use craft_ui::docking::{DockDropTarget, DockDropped, DockGroup, DockSizes, GroupDrag, PanelDrag, PanelKey, PanelTitle, SplitArea, Titles}; use craft_ui::runtime::drag; use craft_ui::style::{ComponentStyle, StyleCx}; use craft_ui::testing::pointer::{moved, press, release}; @@ -130,7 +130,7 @@ fn bed(layout: Layout) -> Bed { for (anchor, panels, rect) in &placed { let titles: Vec = panels.iter().map(|panel| PanelTitle::new(PanelKey::of(panel), panel.clone())).collect(); let active = titles.first().map_or(PanelKey::new(0), |title| title.key); - DockGroup::new(anchor.clone(), &titles, active).dock(dock_id()).show_at(ui, *rect, |_, _| ()); + DockGroup::new(anchor.clone(), Titles::from_content(titles.clone()), active).dock(dock_id()).show_at(ui, *rect, |_, _| ()); } }); for dropped in shared_taken.borrow_mut().drain(..) { diff --git a/crates/ui-patterns/tests/it/docking/hidden.rs b/crates/ui-patterns/tests/it/docking/hidden.rs index 64cfec75e..263178cd0 100644 --- a/crates/ui-patterns/tests/it/docking/hidden.rs +++ b/crates/ui-patterns/tests/it/docking/hidden.rs @@ -3,7 +3,7 @@ use craft_behavior::Axis; use craft_behavior::dock::{Column, DockEdge, Floating, Group, Layout, Node, Permissions, SplitSize, Workspace}; use craft_ui::contract::{Bind, BodyCx, PlainData, Tracked}; -use craft_ui::docking::{DockConfig, DockPanels, HidePanels, PanelSpec, PanelSpecs}; +use craft_ui::docking::{DockConfig, DockPanels, HidePanels, PanelKey, PanelSpec, PanelSpecs}; use craft_ui::patterns::dock::DockArea; use craft_ui::runtime::env::{BodyMode, ShellCx, ShellEntry, WindowKey}; use craft_ui::testing::{Fixture, trial}; @@ -65,7 +65,7 @@ fn shown_under(shell: ShellCx, keeps: bool) -> BTreeSet { let mut workspace = Arc::new(Workspace::new(layout())); let mut panels = Panels { shown: Rc::clone(&seen) }; let specs = Tracked::new(Specs); - let keep = |panel: &usize| *panel == TOOLBAR || *panel == PALETTE; + let keep = Tracked::new(BTreeSet::from([PanelKey::of(&TOOLBAR), PanelKey::of(&PALETTE)])); let mut area = DockArea::new("Hidden dock", Bind::bound(&mut workspace), &specs, &mut panels, DockConfig::default()); if keeps { area = area.hide(HidePanels::Except(&keep)); diff --git a/crates/ui-patterns/tests/it/docking/split.rs b/crates/ui-patterns/tests/it/docking/split.rs index 89df28103..47825ed49 100644 --- a/crates/ui-patterns/tests/it/docking/split.rs +++ b/crates/ui-patterns/tests/it/docking/split.rs @@ -2,14 +2,15 @@ use craft_behavior::Axis; use craft_behavior::dock::{Column, Group, Layout, Node, SplitSize}; -use craft_ui::contract::Role; +use craft_ui::contract::{Role, Tracked}; use craft_ui::docking::frame::maximize; use craft_ui::docking::tree; -use craft_ui::docking::{DockColumn, HidePanels, PanelSpec}; +use craft_ui::docking::{DockColumn, HidePanels, PanelKey, PanelSpec}; use craft_ui::testing::memory::global; use craft_ui::testing::pointer; use craft_ui::testing::{Fixture, trial}; use egui::{Pos2, Rect}; +use std::collections::BTreeSet; use std::cell::RefCell; use std::rc::Rc; @@ -64,7 +65,7 @@ fn a_column_divider_dragged_past_a_minimum_and_back_stays_under_the_pointer() { fn a_resize_under_a_pruned_view_keeps_the_hidden_panels() { let rest = Node::split(Axis::X, SplitSize::Ratio(0.5), Node::tabs(vec![1], 0), Node::tabs(vec![2], 0)); let mut layout = Layout::new(Some(Node::split(Axis::X, SplitSize::Ratio(0.5), Node::tabs(vec![0], 0), rest)), Vec::new()); - let keep = |panel: &usize| *panel != 2; + let keep = Tracked::new(BTreeSet::from([PanelKey::of(&0_usize), PanelKey::of(&1_usize)])); let none_protected = |_: &usize| false; let original = layout.clone(); let view = maximize(&original, None, HidePanels::Except(&keep), &none_protected);