diff options
| author | 2021-05-24 14:28:52 -0500 | |
|---|---|---|
| committer | 2021-05-24 14:28:52 -0500 | |
| commit | e6f8b32583ae00eb77d6e10e3a43c899ecadc88f (patch) | |
| tree | 3be70b2904374078fd2304bc3ee668f5ed17de60 /examples/pane_grid | |
| parent | df971ac99beedb41537763f95f7b14d8bf7475a8 (diff) | |
| download | iced-e6f8b32583ae00eb77d6e10e3a43c899ecadc88f.tar.gz iced-e6f8b32583ae00eb77d6e10e3a43c899ecadc88f.tar.bz2 iced-e6f8b32583ae00eb77d6e10e3a43c899ecadc88f.zip | |
Example: Add close button to pane grid controls
Refactors the state data structure to hold content and controls in
separate fields. Adds a new button style for the control button.
Diffstat (limited to 'examples/pane_grid')
| -rw-r--r-- | examples/pane_grid/src/main.rs | 62 |
1 files changed, 54 insertions, 8 deletions
diff --git a/examples/pane_grid/src/main.rs b/examples/pane_grid/src/main.rs index 4b87a568..7c0d6582 100644 --- a/examples/pane_grid/src/main.rs +++ b/examples/pane_grid/src/main.rs @@ -11,7 +11,7 @@ pub fn main() -> iced::Result { } struct Example { - panes: pane_grid::State<Content>, + panes: pane_grid::State<Pane>, panes_created: usize, focus: Option<pane_grid::Pane>, } @@ -34,7 +34,7 @@ impl Application for Example { type Flags = (); fn new(_flags: ()) -> (Self, Command<Message>) { - let (panes, _) = pane_grid::State::new(Content::new(0)); + let (panes, _) = pane_grid::State::new(Pane::new(0)); ( Example { @@ -60,7 +60,7 @@ impl Application for Example { let result = self.panes.split( axis, &pane, - Content::new(self.panes_created), + Pane::new(self.panes_created), ); if let Some((pane, _)) = result { @@ -74,7 +74,7 @@ impl Application for Example { let result = self.panes.split( axis, &pane, - Content::new(self.panes_created), + Pane::new(self.panes_created), ); if let Some((pane, _)) = result { @@ -143,12 +143,12 @@ impl Application for Example { let focus = self.focus; let total_panes = self.panes.len(); - let pane_grid = PaneGrid::new(&mut self.panes, |pane, content| { - let is_focused = focus == Some(pane); + let pane_grid = PaneGrid::new(&mut self.panes, |id, pane| { + let is_focused = focus == Some(id); let title = Row::with_children(vec