diff options
author | 2024-10-04 11:31:14 -0700 | |
---|---|---|
committer | 2024-10-24 13:05:42 +0200 | |
commit | 9ac3318357d636cde22ae34f7b2cdeddd3f55cdb (patch) | |
tree | 1dbb4095ba62383b076a3ec6cc2ea56ce9feb0f4 /widget/src/pane_grid/state.rs | |
parent | 415fd4f643d385dad39bd0ee5a47de384643dcf3 (diff) | |
download | iced-9ac3318357d636cde22ae34f7b2cdeddd3f55cdb.tar.gz iced-9ac3318357d636cde22ae34f7b2cdeddd3f55cdb.tar.bz2 iced-9ac3318357d636cde22ae34f7b2cdeddd3f55cdb.zip |
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
Diffstat (limited to 'widget/src/pane_grid/state.rs')
-rw-r--r-- | widget/src/pane_grid/state.rs | 14 |
1 files changed, 7 insertions, 7 deletions
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<T> State<T> { /// [`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<Pane>, } |