diff options
author | 2020-06-05 06:52:07 +0200 | |
---|---|---|
committer | 2020-06-05 06:52:07 +0200 | |
commit | 4e1e0e0890b83fb1c4c4406791e3aa63bba58a93 (patch) | |
tree | f74e6712955a4a7239e6a91adfe4c754d876ed52 /graphics | |
parent | a11bcf5af0be26671ba90097c64021014ab2092d (diff) | |
download | iced-4e1e0e0890b83fb1c4c4406791e3aa63bba58a93.tar.gz iced-4e1e0e0890b83fb1c4c4406791e3aa63bba58a93.tar.bz2 iced-4e1e0e0890b83fb1c4c4406791e3aa63bba58a93.zip |
Draft drawing logic for `Content` and `TitleBar`
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/src/widget/pane_grid.rs | 60 |
1 files changed, 56 insertions, 4 deletions
diff --git a/graphics/src/widget/pane_grid.rs b/graphics/src/widget/pane_grid.rs index 7a840689..71b1658a 100644 --- a/graphics/src/widget/pane_grid.rs +++ b/graphics/src/widget/pane_grid.rs @@ -119,11 +119,63 @@ where fn draw_pane<Message>( &mut self, defaults: &Self::Defaults, - _title_bar: Option<&TitleBar<'_, Message, Self>>, - body: &Element<'_, Message, Self>, - layout: Layout<'_>, + title_bar: Option<(&TitleBar<'_, Message, Self>, Layout<'_>)>, + body: (&Element<'_, Message, Self>, Layout<'_>), + cursor_position: Point, + ) -> Self::Output { + let (body, body_layout) = body; + + let (body_primitive, body_interaction) = + body.draw(self, defaults, body_layout, cursor_position); + + if let Some((title_bar, title_bar_layout)) = title_bar { + let (title_bar_primitive, title_bar_interaction) = title_bar.draw( + self, + defaults, + title_bar_layout, + cursor_position, + ); + + ( + Primitive::Group { + primitives: vec![title_bar_primitive, body_primitive], + }, + if title_bar_interaction > body_interaction { + title_bar_interaction + } else { + body_interaction + }, + ) + } else { + (body_primitive, body_interaction) + } + } + + fn draw_title_bar<Message>( + &mut self, + defaults: &Self::Defaults, + style: &<Self as iced_native::container::Renderer>::Style, + title: (&Element<'_, Message, Self>, Layout<'_>), + controls: Option<(&Element<'_, Message, Self>, Layout<'_>)>, cursor_position: Point, ) -> Self::Output { - body.draw(self, defaults, layout, cursor_position) + let (title, title_layout) = title; + + let (title_primitive, _) = + title.draw(self, defaults, title_layout, cursor_position); + + if let Some((controls, controls_layout)) = controls { + let (controls_primitive, controls_interaction) = + controls.draw(self, defaults, controls_layout, cursor_position); + + ( + Primitive::Group { + primitives: vec![title_primitive, controls_primitive], + }, + controls_interaction, + ) + } else { + (title_primitive, mouse::Interaction::default()) + } } } |