From 9ac3318357d636cde22ae34f7b2cdeddd3f55cdb Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Fri, 4 Oct 2024 11:31:14 -0700 Subject: Retain widget state against incoming panes We can associate each state with a `Pane` and compare that against the new panes to remove states w/ respective panes which no longer exist. Because we always increment `Pane`, new states are always added to the end, so this retain + add new state approach will ensure continuity when panes are added & removed --- widget/src/pane_grid/state.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'widget/src/pane_grid') diff --git a/widget/src/pane_grid/state.rs b/widget/src/pane_grid/state.rs index f5d2bb02..e1934930 100644 --- a/widget/src/pane_grid/state.rs +++ b/widget/src/pane_grid/state.rs @@ -343,7 +343,7 @@ impl State { /// [`PaneGrid`]: super::PaneGrid #[derive(Debug, Clone)] pub struct Internal { - layout: Node, + pub(super) layout: Node, last_id: usize, } @@ -397,11 +397,12 @@ impl Internal { /// The current action of a [`PaneGrid`]. /// /// [`PaneGrid`]: super::PaneGrid -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Default)] pub enum Action { /// The [`PaneGrid`] is idle. /// /// [`PaneGrid`]: super::PaneGrid + #[default] Idle, /// A [`Pane`] in the [`PaneGrid`] is being dragged. /// @@ -441,9 +442,8 @@ impl Action { } } -impl Internal { - /// The layout [`Node`] of the [`Internal`] state - pub fn layout(&self) -> &Node { - &self.layout - } +#[derive(Default)] +pub(super) struct Widget { + pub action: Action, + pub panes: Vec, } -- cgit