Merge pull request #657 from clarkmoody/feature/pane-grid-title-contents
Generic Element Content in Pane Grid TitleBar
This commit is contained in:
commit
f8aef03456
5 changed files with 81 additions and 114 deletions
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue