From 35b1b8b0e72bd57ddc793624c6c26c1f0c3eb9e1 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 22 Jul 2020 02:58:14 +0200 Subject: Add `focused` method to `pane_grid::State` --- native/src/widget/pane_grid/state.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'native') diff --git a/native/src/widget/pane_grid/state.rs b/native/src/widget/pane_grid/state.rs index e1585968..f537c7de 100644 --- a/native/src/widget/pane_grid/state.rs +++ b/native/src/widget/pane_grid/state.rs @@ -122,6 +122,14 @@ impl State { &self.internal.layout } + /// Returns the focused [`Pane`] of the [`State`], if there is one. + /// + /// [`Pane`]: struct.Pane.html + /// [`State`]: struct.State.html + pub fn focused(&self) -> Option { + self.internal.focused_pane() + } + /// Returns the active [`Pane`] of the [`State`], if there is one. /// /// A [`Pane`] is active if it is focused and is __not__ being dragged. @@ -351,6 +359,14 @@ impl Internal { self.action } + pub fn focused_pane(&self) -> Option { + match self.action { + Action::Idle { focus } => focus, + Action::Dragging { pane, .. } => Some(pane), + Action::Resizing { focus, .. } => focus, + } + } + pub fn active_pane(&self) -> Option { match self.action { Action::Idle { focus } => focus, -- cgit