Implement Widget::operate for PaneGrid

This commit is contained in:
Ryan Scheidter 2022-11-13 14:21:27 -06:00 committed by Héctor Ramón Jiménez
parent 23299a555f
commit b0678f4c75
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
3 changed files with 85 additions and 2 deletions

View file

@ -5,7 +5,7 @@ use crate::overlay;
use crate::renderer;
use crate::widget::container;
use crate::widget::pane_grid::{Draggable, TitleBar};
use crate::widget::Tree;
use crate::widget::{self, Tree};
use crate::{Clipboard, Element, Layout, Point, Rectangle, Shell, Size};
/// The content of a [`Pane`].
@ -183,6 +183,33 @@ where
}
}
pub(crate) fn operate(
&self,
tree: &mut Tree,
layout: Layout<'_>,
operation: &mut dyn widget::Operation<Message>,
) {
let body_layout = if let Some(title_bar) = &self.title_bar {
let mut children = layout.children();
title_bar.operate(
&mut tree.children[1],
children.next().unwrap(),
operation,
);
children.next().unwrap()
} else {
layout
};
self.body.as_widget().operate(
&mut tree.children[0],
body_layout,
operation,
);
}
pub(crate) fn on_event(
&mut self,
tree: &mut Tree,