summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-06-10 16:27:28 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-06-10 16:27:28 +0200
commit3cfe6e428be22fdbf715f1f28caec0c802fd069e (patch)
tree372809f6d7a150ed94c484aeca1cb92f076492af /graphics
parentac7816e8caa1f4fea02fc740c6c84f4439206795 (diff)
downloadiced-3cfe6e428be22fdbf715f1f28caec0c802fd069e.tar.gz
iced-3cfe6e428be22fdbf715f1f28caec0c802fd069e.tar.bz2
iced-3cfe6e428be22fdbf715f1f28caec0c802fd069e.zip
Lay out title text dynamically in `TitleBar`
Diffstat (limited to 'graphics')
-rw-r--r--graphics/src/widget/pane_grid.rs30
1 files changed, 23 insertions, 7 deletions
diff --git a/graphics/src/widget/pane_grid.rs b/graphics/src/widget/pane_grid.rs
index 27b4f211..ec607c47 100644
--- a/graphics/src/widget/pane_grid.rs
+++ b/graphics/src/widget/pane_grid.rs
@@ -8,10 +8,15 @@
//!
//! [`pane_grid` example]: https://github.com/hecrj/iced/tree/0.1/examples/pane_grid
//! [`PaneGrid`]: type.PaneGrid.html
-use crate::{Backend, Primitive, Renderer};
+use crate::backend::{self, Backend};
+use crate::{Primitive, Renderer};
use iced_native::mouse;
use iced_native::pane_grid;
-use iced_native::{Element, Layout, Point, Rectangle, Vector};
+use iced_native::text;
+use iced_native::{
+ Element, HorizontalAlignment, Layout, Point, Rectangle, Vector,
+ VerticalAlignment,
+};
pub use iced_native::pane_grid::{
Axis, Configuration, Content, Direction, DragEvent, Focus, KeyPressEvent,
@@ -29,7 +34,7 @@ pub type PaneGrid<'a, Message, Backend> =
impl<B> pane_grid::Renderer for Renderer<B>
where
- B: Backend,
+ B: Backend + backend::Text,
{
fn draw<Message>(
&mut self,
@@ -189,17 +194,28 @@ where
defaults: &Self::Defaults,
bounds: Rectangle,
style_sheet: &Self::Style,
- title: (&Element<'_, Message, Self>, Layout<'_>),
+ title: &str,
+ title_size: u16,
+ title_font: Self::Font,
+ title_bounds: Rectangle,
controls: Option<(&Element<'_, Message, Self>, Layout<'_>)>,
cursor_position: Point,
) -> Self::Output {
let style = style_sheet.style();
- let (title, title_layout) = title;
let background = crate::widget::container::background(bounds, &style);
- let (title_primitive, _) =
- title.draw(self, defaults, title_layout, cursor_position);
+ let (title_primitive, _) = text::Renderer::draw(
+ self,
+ defaults,
+ title_bounds,
+ title,
+ title_size,
+ title_font,
+ None,
+ HorizontalAlignment::Left,
+ VerticalAlignment::Top,
+ );
if let Some((controls, controls_layout)) = controls {
let (controls_primitive, controls_interaction) =