summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2020-12-22 14:58:39 +0100
committerLibravatar GitHub <noreply@github.com>2020-12-22 14:58:39 +0100
commitf8aef03456ecc185098b6305a8cd0e22f5297d06 (patch)
treebdd8fd190980840235c4d10365cac98f3a260c21 /graphics
parenta366600e7347c24bbb6679118a12b616a031deff (diff)
parente815c5bbd72f618ad890e1d3c5a67c811cd07108 (diff)
downloadiced-f8aef03456ecc185098b6305a8cd0e22f5297d06.tar.gz
iced-f8aef03456ecc185098b6305a8cd0e22f5297d06.tar.bz2
iced-f8aef03456ecc185098b6305a8cd0e22f5297d06.zip
Merge pull request #657 from clarkmoody/feature/pane-grid-title-contents
Generic Element Content in Pane Grid TitleBar
Diffstat (limited to 'graphics')
-rw-r--r--graphics/src/widget/pane_grid.rs33
1 files changed, 11 insertions, 22 deletions
diff --git a/graphics/src/widget/pane_grid.rs b/graphics/src/widget/pane_grid.rs
index f09984fc..29478447 100644
--- a/graphics/src/widget/pane_grid.rs
+++ b/graphics/src/widget/pane_grid.rs
@@ -7,16 +7,11 @@
//! drag and drop, and hotkey support.
//!
//! [`pane_grid` example]: https://github.com/hecrj/iced/tree/0.2/examples/pane_grid
-use crate::backend::{self, Backend};
use crate::defaults;
-use crate::{Primitive, Renderer};
+use crate::{Backend, Primitive, Renderer};
use iced_native::mouse;
use iced_native::pane_grid;
-use iced_native::text;
-use iced_native::{
- Element, HorizontalAlignment, Layout, Point, Rectangle, Vector,
- VerticalAlignment,
-};
+use iced_native::{Element, Layout, Point, Rectangle, Vector};
pub use iced_native::pane_grid::{
Axis, Configuration, Content, Direction, DragEvent, Pane, ResizeEvent,
@@ -34,7 +29,7 @@ pub type PaneGrid<'a, Message, Backend> =
impl<B> pane_grid::Renderer for Renderer<B>
where
- B: Backend + backend::Text,
+ B: Backend,
{
fn draw<Message>(
&mut self,
@@ -188,14 +183,12 @@ where
defaults: &Self::Defaults,
bounds: Rectangle,
style_sheet: &Self::Style,
- title: &str,
- title_size: u16,
- title_font: Self::Font,
- title_bounds: Rectangle,
+ content: (&Element<'_, Message, Self>, Layout<'_>),
controls: Option<(&Element<'_, Message, Self>, Layout<'_>)>,
cursor_position: Point,
) -> Self::Output {
let style = style_sheet.style();
+ let (title_content, title_layout) = content;
let defaults = Self::Defaults {
text: defaults::Text {
@@ -205,16 +198,12 @@ where
let background = crate::widget::container::background(bounds, &style);
- let (title_primitive, _) = text::Renderer::draw(
+ let (title_primitive, title_interaction) = title_content.draw(
self,
&defaults,
- title_bounds,
- title,
- title_size,
- title_font,
- None,
- HorizontalAlignment::Left,
- VerticalAlignment::Top,
+ title_layout,
+ cursor_position,
+ &bounds,
);
if let Some((controls, controls_layout)) = controls {
@@ -234,7 +223,7 @@ where
controls_primitive,
],
},
- controls_interaction,
+ controls_interaction.max(title_interaction),
)
} else {
(
@@ -245,7 +234,7 @@ where
} else {
title_primitive
},
- mouse::Interaction::default(),
+ title_interaction,
)
}
}