Introduce `viewport` to `Widget::draw`
This should eventually allow us to only generate primitives that are visible.
This commit is contained in:
parent
8a3ce90959
commit
d328b07b39
|
@ -12,7 +12,7 @@ mod circle {
|
||||||
use iced_graphics::{Backend, Defaults, Primitive, Renderer};
|
use iced_graphics::{Backend, Defaults, Primitive, Renderer};
|
||||||
use iced_native::{
|
use iced_native::{
|
||||||
layout, mouse, Background, Color, Element, Hasher, Layout, Length,
|
layout, mouse, Background, Color, Element, Hasher, Layout, Length,
|
||||||
Point, Size, Widget,
|
Point, Rectangle, Size, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Circle {
|
pub struct Circle {
|
||||||
|
@ -60,6 +60,7 @@ mod circle {
|
||||||
_defaults: &Defaults,
|
_defaults: &Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
_cursor_position: Point,
|
_cursor_position: Point,
|
||||||
|
_viewport: &Rectangle,
|
||||||
) -> (Primitive, mouse::Interaction) {
|
) -> (Primitive, mouse::Interaction) {
|
||||||
(
|
(
|
||||||
Primitive::Quad {
|
Primitive::Quad {
|
||||||
|
|
|
@ -15,8 +15,8 @@ mod rainbow {
|
||||||
Backend, Defaults, Primitive, Renderer,
|
Backend, Defaults, Primitive, Renderer,
|
||||||
};
|
};
|
||||||
use iced_native::{
|
use iced_native::{
|
||||||
layout, mouse, Element, Hasher, Layout, Length, Point, Size, Vector,
|
layout, mouse, Element, Hasher, Layout, Length, Point, Rectangle, Size,
|
||||||
Widget,
|
Vector, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Rainbow;
|
pub struct Rainbow;
|
||||||
|
@ -57,6 +57,7 @@ mod rainbow {
|
||||||
_defaults: &Defaults,
|
_defaults: &Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
_viewport: &Rectangle,
|
||||||
) -> (Primitive, mouse::Interaction) {
|
) -> (Primitive, mouse::Interaction) {
|
||||||
let b = layout.bounds();
|
let b = layout.bounds();
|
||||||
|
|
||||||
|
|
|
@ -96,10 +96,11 @@ where
|
||||||
widget: &dyn Widget<Message, Self>,
|
widget: &dyn Widget<Message, Self>,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
viewport: &Rectangle,
|
||||||
color: Color,
|
color: Color,
|
||||||
) -> Self::Output {
|
) -> Self::Output {
|
||||||
let (primitive, cursor) =
|
let (primitive, cursor) =
|
||||||
widget.draw(self, defaults, layout, cursor_position);
|
widget.draw(self, defaults, layout, cursor_position, viewport);
|
||||||
|
|
||||||
let mut primitives = Vec::new();
|
let mut primitives = Vec::new();
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@ where
|
||||||
},
|
},
|
||||||
content_layout,
|
content_layout,
|
||||||
cursor_position,
|
cursor_position,
|
||||||
|
&bounds,
|
||||||
);
|
);
|
||||||
|
|
||||||
(
|
(
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
//! [`Frame`]: struct.Frame.html
|
//! [`Frame`]: struct.Frame.html
|
||||||
use crate::{Backend, Defaults, Primitive, Renderer};
|
use crate::{Backend, Defaults, Primitive, Renderer};
|
||||||
use iced_native::{
|
use iced_native::{
|
||||||
layout, mouse, Clipboard, Element, Hasher, Layout, Length, Point, Size,
|
layout, mouse, Clipboard, Element, Hasher, Layout, Length, Point,
|
||||||
Vector, Widget,
|
Rectangle, Size, Vector, Widget,
|
||||||
};
|
};
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
@ -196,6 +196,7 @@ where
|
||||||
_defaults: &Defaults,
|
_defaults: &Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
_viewport: &Rectangle,
|
||||||
) -> (Primitive, mouse::Interaction) {
|
) -> (Primitive, mouse::Interaction) {
|
||||||
let bounds = layout.bounds();
|
let bounds = layout.bounds();
|
||||||
let translation = Vector::new(bounds.x, bounds.y);
|
let translation = Vector::new(bounds.x, bounds.y);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::{Backend, Primitive, Renderer};
|
use crate::{Backend, Primitive, Renderer};
|
||||||
use iced_native::column;
|
use iced_native::column;
|
||||||
use iced_native::mouse;
|
use iced_native::mouse;
|
||||||
use iced_native::{Element, Layout, Point};
|
use iced_native::{Element, Layout, Point, Rectangle};
|
||||||
|
|
||||||
/// A container that distributes its contents vertically.
|
/// A container that distributes its contents vertically.
|
||||||
pub type Column<'a, Message, Backend> =
|
pub type Column<'a, Message, Backend> =
|
||||||
|
@ -17,6 +17,7 @@ where
|
||||||
content: &[Element<'_, Message, Self>],
|
content: &[Element<'_, Message, Self>],
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
viewport: &Rectangle,
|
||||||
) -> Self::Output {
|
) -> Self::Output {
|
||||||
let mut mouse_interaction = mouse::Interaction::default();
|
let mut mouse_interaction = mouse::Interaction::default();
|
||||||
|
|
||||||
|
@ -26,8 +27,13 @@ where
|
||||||
.iter()
|
.iter()
|
||||||
.zip(layout.children())
|
.zip(layout.children())
|
||||||
.map(|(child, layout)| {
|
.map(|(child, layout)| {
|
||||||
let (primitive, new_mouse_interaction) =
|
let (primitive, new_mouse_interaction) = child.draw(
|
||||||
child.draw(self, defaults, layout, cursor_position);
|
self,
|
||||||
|
defaults,
|
||||||
|
layout,
|
||||||
|
cursor_position,
|
||||||
|
viewport,
|
||||||
|
);
|
||||||
|
|
||||||
if new_mouse_interaction > mouse_interaction {
|
if new_mouse_interaction > mouse_interaction {
|
||||||
mouse_interaction = new_mouse_interaction;
|
mouse_interaction = new_mouse_interaction;
|
||||||
|
|
|
@ -24,6 +24,7 @@ where
|
||||||
defaults: &Defaults,
|
defaults: &Defaults,
|
||||||
bounds: Rectangle,
|
bounds: Rectangle,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
viewport: &Rectangle,
|
||||||
style_sheet: &Self::Style,
|
style_sheet: &Self::Style,
|
||||||
content: &Element<'_, Message, Self>,
|
content: &Element<'_, Message, Self>,
|
||||||
content_layout: Layout<'_>,
|
content_layout: Layout<'_>,
|
||||||
|
@ -36,8 +37,13 @@ where
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let (content, mouse_interaction) =
|
let (content, mouse_interaction) = content.draw(
|
||||||
content.draw(self, &defaults, content_layout, cursor_position);
|
self,
|
||||||
|
&defaults,
|
||||||
|
content_layout,
|
||||||
|
cursor_position,
|
||||||
|
viewport,
|
||||||
|
);
|
||||||
|
|
||||||
if let Some(background) = background(bounds, &style) {
|
if let Some(background) = background(bounds, &style) {
|
||||||
(
|
(
|
||||||
|
|
|
@ -137,7 +137,7 @@ where
|
||||||
let (body, body_layout) = body;
|
let (body, body_layout) = body;
|
||||||
|
|
||||||
let (body_primitive, body_interaction) =
|
let (body_primitive, body_interaction) =
|
||||||
body.draw(self, defaults, body_layout, cursor_position);
|
body.draw(self, defaults, body_layout, cursor_position, &bounds);
|
||||||
|
|
||||||
let background = crate::widget::container::background(bounds, &style);
|
let background = crate::widget::container::background(bounds, &style);
|
||||||
|
|
||||||
|
@ -224,6 +224,7 @@ where
|
||||||
&defaults,
|
&defaults,
|
||||||
controls_layout,
|
controls_layout,
|
||||||
cursor_position,
|
cursor_position,
|
||||||
|
&bounds,
|
||||||
);
|
);
|
||||||
|
|
||||||
(
|
(
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::{Backend, Primitive, Renderer};
|
use crate::{Backend, Primitive, Renderer};
|
||||||
use iced_native::mouse;
|
use iced_native::mouse;
|
||||||
use iced_native::row;
|
use iced_native::row;
|
||||||
use iced_native::{Element, Layout, Point};
|
use iced_native::{Element, Layout, Point, Rectangle};
|
||||||
|
|
||||||
/// A container that distributes its contents horizontally.
|
/// A container that distributes its contents horizontally.
|
||||||
pub type Row<'a, Message, Backend> =
|
pub type Row<'a, Message, Backend> =
|
||||||
|
@ -17,6 +17,7 @@ where
|
||||||
content: &[Element<'_, Message, Self>],
|
content: &[Element<'_, Message, Self>],
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
viewport: &Rectangle,
|
||||||
) -> Self::Output {
|
) -> Self::Output {
|
||||||
let mut mouse_interaction = mouse::Interaction::default();
|
let mut mouse_interaction = mouse::Interaction::default();
|
||||||
|
|
||||||
|
@ -26,8 +27,13 @@ where
|
||||||
.iter()
|
.iter()
|
||||||
.zip(layout.children())
|
.zip(layout.children())
|
||||||
.map(|(child, layout)| {
|
.map(|(child, layout)| {
|
||||||
let (primitive, new_mouse_interaction) =
|
let (primitive, new_mouse_interaction) = child.draw(
|
||||||
child.draw(self, defaults, layout, cursor_position);
|
self,
|
||||||
|
defaults,
|
||||||
|
layout,
|
||||||
|
cursor_position,
|
||||||
|
viewport,
|
||||||
|
);
|
||||||
|
|
||||||
if new_mouse_interaction > mouse_interaction {
|
if new_mouse_interaction > mouse_interaction {
|
||||||
mouse_interaction = new_mouse_interaction;
|
mouse_interaction = new_mouse_interaction;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
use crate::layout;
|
||||||
|
use crate::overlay;
|
||||||
use crate::{
|
use crate::{
|
||||||
layout, overlay, Clipboard, Color, Event, Hasher, Layout, Length, Point,
|
Clipboard, Color, Event, Hasher, Layout, Length, Point, Rectangle, Widget,
|
||||||
Widget,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A generic [`Widget`].
|
/// A generic [`Widget`].
|
||||||
|
@ -260,9 +261,10 @@ where
|
||||||
defaults: &Renderer::Defaults,
|
defaults: &Renderer::Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
viewport: &Rectangle,
|
||||||
) -> Renderer::Output {
|
) -> Renderer::Output {
|
||||||
self.widget
|
self.widget
|
||||||
.draw(renderer, defaults, layout, cursor_position)
|
.draw(renderer, defaults, layout, cursor_position, viewport)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Computes the _layout_ hash of the [`Element`].
|
/// Computes the _layout_ hash of the [`Element`].
|
||||||
|
@ -356,9 +358,10 @@ where
|
||||||
defaults: &Renderer::Defaults,
|
defaults: &Renderer::Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
viewport: &Rectangle,
|
||||||
) -> Renderer::Output {
|
) -> Renderer::Output {
|
||||||
self.widget
|
self.widget
|
||||||
.draw(renderer, defaults, layout, cursor_position)
|
.draw(renderer, defaults, layout, cursor_position, viewport)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hash_layout(&self, state: &mut Hasher) {
|
fn hash_layout(&self, state: &mut Hasher) {
|
||||||
|
@ -437,12 +440,14 @@ where
|
||||||
defaults: &Renderer::Defaults,
|
defaults: &Renderer::Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
viewport: &Rectangle,
|
||||||
) -> Renderer::Output {
|
) -> Renderer::Output {
|
||||||
renderer.explain(
|
renderer.explain(
|
||||||
defaults,
|
defaults,
|
||||||
self.element.widget.as_ref(),
|
self.element.widget.as_ref(),
|
||||||
layout,
|
layout,
|
||||||
cursor_position,
|
cursor_position,
|
||||||
|
viewport,
|
||||||
self.color,
|
self.color,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{Color, Layout, Point, Renderer, Widget};
|
use crate::{Color, Layout, Point, Rectangle, Renderer, Widget};
|
||||||
|
|
||||||
/// A renderer able to graphically explain a [`Layout`].
|
/// A renderer able to graphically explain a [`Layout`].
|
||||||
///
|
///
|
||||||
|
@ -21,6 +21,7 @@ pub trait Debugger: Renderer {
|
||||||
widget: &dyn Widget<Message, Self>,
|
widget: &dyn Widget<Message, Self>,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
viewport: &Rectangle,
|
||||||
color: Color,
|
color: Color,
|
||||||
) -> Self::Output;
|
) -> Self::Output;
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,9 +253,13 @@ where
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
) -> Renderer::Output {
|
) -> Renderer::Output {
|
||||||
let primitives =
|
let primitives = self.container.draw(
|
||||||
self.container
|
renderer,
|
||||||
.draw(renderer, defaults, layout, cursor_position);
|
defaults,
|
||||||
|
layout,
|
||||||
|
cursor_position,
|
||||||
|
&layout.bounds(),
|
||||||
|
);
|
||||||
|
|
||||||
renderer.decorate(
|
renderer.decorate(
|
||||||
layout.bounds(),
|
layout.bounds(),
|
||||||
|
@ -368,6 +372,7 @@ where
|
||||||
_defaults: &Renderer::Defaults,
|
_defaults: &Renderer::Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
_viewport: &Rectangle,
|
||||||
) -> Renderer::Output {
|
) -> Renderer::Output {
|
||||||
self::Renderer::draw(
|
self::Renderer::draw(
|
||||||
renderer,
|
renderer,
|
||||||
|
|
|
@ -35,6 +35,7 @@ impl column::Renderer for Null {
|
||||||
_content: &[Element<'_, Message, Self>],
|
_content: &[Element<'_, Message, Self>],
|
||||||
_layout: Layout<'_>,
|
_layout: Layout<'_>,
|
||||||
_cursor_position: Point,
|
_cursor_position: Point,
|
||||||
|
_viewport: &Rectangle,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,6 +47,7 @@ impl row::Renderer for Null {
|
||||||
_content: &[Element<'_, Message, Self>],
|
_content: &[Element<'_, Message, Self>],
|
||||||
_layout: Layout<'_>,
|
_layout: Layout<'_>,
|
||||||
_cursor_position: Point,
|
_cursor_position: Point,
|
||||||
|
_viewport: &Rectangle,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -237,6 +239,7 @@ impl container::Renderer for Null {
|
||||||
_defaults: &Self::Defaults,
|
_defaults: &Self::Defaults,
|
||||||
_bounds: Rectangle,
|
_bounds: Rectangle,
|
||||||
_cursor_position: Point,
|
_cursor_position: Point,
|
||||||
|
_viewport: &Rectangle,
|
||||||
_style: &Self::Style,
|
_style: &Self::Style,
|
||||||
_content: &Element<'_, Message, Self>,
|
_content: &Element<'_, Message, Self>,
|
||||||
_content_layout: Layout<'_>,
|
_content_layout: Layout<'_>,
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
use crate::{layout, overlay, Clipboard, Element, Event, Layout, Point, Size};
|
use crate::layout;
|
||||||
|
use crate::overlay;
|
||||||
|
use crate::{Clipboard, Element, Event, Layout, Point, Rectangle, Size};
|
||||||
|
|
||||||
use std::hash::Hasher;
|
use std::hash::Hasher;
|
||||||
|
|
||||||
|
@ -327,6 +329,8 @@ where
|
||||||
renderer: &mut Renderer,
|
renderer: &mut Renderer,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
) -> Renderer::Output {
|
) -> Renderer::Output {
|
||||||
|
let viewport = Rectangle::with_size(self.bounds);
|
||||||
|
|
||||||
let overlay = if let Some(mut overlay) =
|
let overlay = if let Some(mut overlay) =
|
||||||
self.root.overlay(Layout::new(&self.base.layout))
|
self.root.overlay(Layout::new(&self.base.layout))
|
||||||
{
|
{
|
||||||
|
@ -365,6 +369,7 @@ where
|
||||||
&Renderer::Defaults::default(),
|
&Renderer::Defaults::default(),
|
||||||
Layout::new(&self.base.layout),
|
Layout::new(&self.base.layout),
|
||||||
base_cursor,
|
base_cursor,
|
||||||
|
&viewport,
|
||||||
);
|
);
|
||||||
|
|
||||||
renderer.overlay(
|
renderer.overlay(
|
||||||
|
@ -378,6 +383,7 @@ where
|
||||||
&Renderer::Defaults::default(),
|
&Renderer::Defaults::default(),
|
||||||
Layout::new(&self.base.layout),
|
Layout::new(&self.base.layout),
|
||||||
cursor_position,
|
cursor_position,
|
||||||
|
&viewport,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,9 @@ pub use text::Text;
|
||||||
#[doc(no_inline)]
|
#[doc(no_inline)]
|
||||||
pub use text_input::TextInput;
|
pub use text_input::TextInput;
|
||||||
|
|
||||||
use crate::{layout, overlay, Clipboard, Event, Hasher, Layout, Length, Point};
|
use crate::{
|
||||||
|
layout, overlay, Clipboard, Event, Hasher, Layout, Length, Point, Rectangle,
|
||||||
|
};
|
||||||
|
|
||||||
/// A component that displays information and allows interaction.
|
/// A component that displays information and allows interaction.
|
||||||
///
|
///
|
||||||
|
@ -137,6 +139,7 @@ where
|
||||||
defaults: &Renderer::Defaults,
|
defaults: &Renderer::Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
viewport: &Rectangle,
|
||||||
) -> Renderer::Output;
|
) -> Renderer::Output;
|
||||||
|
|
||||||
/// Computes the _layout_ hash of the [`Widget`].
|
/// Computes the _layout_ hash of the [`Widget`].
|
||||||
|
|
|
@ -217,6 +217,7 @@ where
|
||||||
defaults: &Renderer::Defaults,
|
defaults: &Renderer::Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
_viewport: &Rectangle,
|
||||||
) -> Renderer::Output {
|
) -> Renderer::Output {
|
||||||
renderer.draw(
|
renderer.draw(
|
||||||
defaults,
|
defaults,
|
||||||
|
|
|
@ -180,6 +180,7 @@ where
|
||||||
defaults: &Renderer::Defaults,
|
defaults: &Renderer::Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
_viewport: &Rectangle,
|
||||||
) -> Renderer::Output {
|
) -> Renderer::Output {
|
||||||
let bounds = layout.bounds();
|
let bounds = layout.bounds();
|
||||||
let mut children = layout.children();
|
let mut children = layout.children();
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
//! Distribute content vertically.
|
//! Distribute content vertically.
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
|
||||||
|
use crate::layout;
|
||||||
|
use crate::overlay;
|
||||||
use crate::{
|
use crate::{
|
||||||
layout, overlay, Align, Clipboard, Element, Event, Hasher, Layout, Length,
|
Align, Clipboard, Element, Event, Hasher, Layout, Length, Point, Rectangle,
|
||||||
Point, Widget,
|
Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::u32;
|
use std::u32;
|
||||||
|
@ -181,8 +183,15 @@ where
|
||||||
defaults: &Renderer::Defaults,
|
defaults: &Renderer::Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
viewport: &Rectangle,
|
||||||
) -> Renderer::Output {
|
) -> Renderer::Output {
|
||||||
renderer.draw(defaults, &self.children, layout, cursor_position)
|
renderer.draw(
|
||||||
|
defaults,
|
||||||
|
&self.children,
|
||||||
|
layout,
|
||||||
|
cursor_position,
|
||||||
|
viewport,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hash_layout(&self, state: &mut Hasher) {
|
fn hash_layout(&self, state: &mut Hasher) {
|
||||||
|
@ -237,6 +246,7 @@ pub trait Renderer: crate::Renderer + Sized {
|
||||||
content: &[Element<'_, Message, Self>],
|
content: &[Element<'_, Message, Self>],
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
viewport: &Rectangle,
|
||||||
) -> Self::Output;
|
) -> Self::Output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -191,11 +191,13 @@ where
|
||||||
defaults: &Renderer::Defaults,
|
defaults: &Renderer::Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
viewport: &Rectangle,
|
||||||
) -> Renderer::Output {
|
) -> Renderer::Output {
|
||||||
renderer.draw(
|
renderer.draw(
|
||||||
defaults,
|
defaults,
|
||||||
layout.bounds(),
|
layout.bounds(),
|
||||||
cursor_position,
|
cursor_position,
|
||||||
|
viewport,
|
||||||
&self.style,
|
&self.style,
|
||||||
&self.content,
|
&self.content,
|
||||||
layout.children().next().unwrap(),
|
layout.children().next().unwrap(),
|
||||||
|
@ -242,6 +244,7 @@ pub trait Renderer: crate::Renderer {
|
||||||
defaults: &Self::Defaults,
|
defaults: &Self::Defaults,
|
||||||
bounds: Rectangle,
|
bounds: Rectangle,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
viewport: &Rectangle,
|
||||||
style: &Self::Style,
|
style: &Self::Style,
|
||||||
content: &Element<'_, Message, Self>,
|
content: &Element<'_, Message, Self>,
|
||||||
content_layout: Layout<'_>,
|
content_layout: Layout<'_>,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
//! Display images in your user interface.
|
//! Display images in your user interface.
|
||||||
use crate::{layout, Element, Hasher, Layout, Length, Point, Size, Widget};
|
use crate::layout;
|
||||||
|
use crate::{Element, Hasher, Layout, Length, Point, Rectangle, Size, Widget};
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
hash::{Hash, Hasher as _},
|
hash::{Hash, Hasher as _},
|
||||||
|
@ -97,6 +98,7 @@ where
|
||||||
_defaults: &Renderer::Defaults,
|
_defaults: &Renderer::Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
_cursor_position: Point,
|
_cursor_position: Point,
|
||||||
|
_viewport: &Rectangle,
|
||||||
) -> Renderer::Output {
|
) -> Renderer::Output {
|
||||||
renderer.draw(self.handle.clone(), layout)
|
renderer.draw(self.handle.clone(), layout)
|
||||||
}
|
}
|
||||||
|
|
|
@ -588,6 +588,7 @@ where
|
||||||
defaults: &Renderer::Defaults,
|
defaults: &Renderer::Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
_viewport: &Rectangle,
|
||||||
) -> Renderer::Output {
|
) -> Renderer::Output {
|
||||||
let picked_split = self
|
let picked_split = self
|
||||||
.state
|
.state
|
||||||
|
|
|
@ -256,6 +256,7 @@ where
|
||||||
_defaults: &Renderer::Defaults,
|
_defaults: &Renderer::Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
_viewport: &Rectangle,
|
||||||
) -> Renderer::Output {
|
) -> Renderer::Output {
|
||||||
self::Renderer::draw(
|
self::Renderer::draw(
|
||||||
renderer,
|
renderer,
|
||||||
|
|
|
@ -104,6 +104,7 @@ where
|
||||||
_defaults: &Renderer::Defaults,
|
_defaults: &Renderer::Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
_cursor_position: Point,
|
_cursor_position: Point,
|
||||||
|
_viewport: &Rectangle,
|
||||||
) -> Renderer::Output {
|
) -> Renderer::Output {
|
||||||
renderer.draw(
|
renderer.draw(
|
||||||
layout.bounds(),
|
layout.bounds(),
|
||||||
|
|
|
@ -183,6 +183,7 @@ where
|
||||||
defaults: &Renderer::Defaults,
|
defaults: &Renderer::Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
_viewport: &Rectangle,
|
||||||
) -> Renderer::Output {
|
) -> Renderer::Output {
|
||||||
let bounds = layout.bounds();
|
let bounds = layout.bounds();
|
||||||
let mut children = layout.children();
|
let mut children = layout.children();
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
//! Distribute content horizontally.
|
//! Distribute content horizontally.
|
||||||
use std::hash::Hash;
|
use crate::layout;
|
||||||
|
use crate::overlay;
|
||||||
use crate::{
|
use crate::{
|
||||||
layout, overlay, Align, Clipboard, Element, Event, Hasher, Layout, Length,
|
Align, Clipboard, Element, Event, Hasher, Layout, Length, Point, Rectangle,
|
||||||
Point, Widget,
|
Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use std::hash::Hash;
|
||||||
use std::u32;
|
use std::u32;
|
||||||
|
|
||||||
/// A container that distributes its contents horizontally.
|
/// A container that distributes its contents horizontally.
|
||||||
|
@ -182,8 +183,15 @@ where
|
||||||
defaults: &Renderer::Defaults,
|
defaults: &Renderer::Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
viewport: &Rectangle,
|
||||||
) -> Renderer::Output {
|
) -> Renderer::Output {
|
||||||
renderer.draw(defaults, &self.children, layout, cursor_position)
|
renderer.draw(
|
||||||
|
defaults,
|
||||||
|
&self.children,
|
||||||
|
layout,
|
||||||
|
cursor_position,
|
||||||
|
viewport,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hash_layout(&self, state: &mut Hasher) {
|
fn hash_layout(&self, state: &mut Hasher) {
|
||||||
|
@ -238,6 +246,7 @@ pub trait Renderer: crate::Renderer + Sized {
|
||||||
children: &[Element<'_, Message, Self>],
|
children: &[Element<'_, Message, Self>],
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
viewport: &Rectangle,
|
||||||
) -> Self::Output;
|
) -> Self::Output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -303,6 +303,7 @@ where
|
||||||
defaults: &Renderer::Defaults,
|
defaults: &Renderer::Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
_viewport: &Rectangle,
|
||||||
) -> Renderer::Output {
|
) -> Renderer::Output {
|
||||||
let bounds = layout.bounds();
|
let bounds = layout.bounds();
|
||||||
let content_layout = layout.children().next().unwrap();
|
let content_layout = layout.children().next().unwrap();
|
||||||
|
@ -335,6 +336,10 @@ where
|
||||||
defaults,
|
defaults,
|
||||||
content_layout,
|
content_layout,
|
||||||
cursor_position,
|
cursor_position,
|
||||||
|
&Rectangle {
|
||||||
|
y: bounds.y + offset as f32,
|
||||||
|
..bounds
|
||||||
|
},
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -259,6 +259,7 @@ where
|
||||||
_defaults: &Renderer::Defaults,
|
_defaults: &Renderer::Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
_viewport: &Rectangle,
|
||||||
) -> Renderer::Output {
|
) -> Renderer::Output {
|
||||||
let start = *self.range.start();
|
let start = *self.range.start();
|
||||||
let end = *self.range.end();
|
let end = *self.range.end();
|
||||||
|
|
|
@ -71,6 +71,7 @@ where
|
||||||
_defaults: &Renderer::Defaults,
|
_defaults: &Renderer::Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
_cursor_position: Point,
|
_cursor_position: Point,
|
||||||
|
_viewport: &Rectangle,
|
||||||
) -> Renderer::Output {
|
) -> Renderer::Output {
|
||||||
renderer.draw(layout.bounds())
|
renderer.draw(layout.bounds())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
//! Display vector graphics in your application.
|
//! Display vector graphics in your application.
|
||||||
use crate::{layout, Element, Hasher, Layout, Length, Point, Size, Widget};
|
use crate::layout;
|
||||||
|
use crate::{Element, Hasher, Layout, Length, Point, Rectangle, Size, Widget};
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
hash::{Hash, Hasher as _},
|
hash::{Hash, Hasher as _},
|
||||||
|
@ -103,6 +104,7 @@ where
|
||||||
_defaults: &Renderer::Defaults,
|
_defaults: &Renderer::Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
_cursor_position: Point,
|
_cursor_position: Point,
|
||||||
|
_viewport: &Rectangle,
|
||||||
) -> Renderer::Output {
|
) -> Renderer::Output {
|
||||||
renderer.draw(self.handle.clone(), layout)
|
renderer.draw(self.handle.clone(), layout)
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,6 +149,7 @@ where
|
||||||
defaults: &Renderer::Defaults,
|
defaults: &Renderer::Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
_cursor_position: Point,
|
_cursor_position: Point,
|
||||||
|
_viewport: &Rectangle,
|
||||||
) -> Renderer::Output {
|
) -> Renderer::Output {
|
||||||
renderer.draw(
|
renderer.draw(
|
||||||
defaults,
|
defaults,
|
||||||
|
|
|
@ -497,6 +497,7 @@ where
|
||||||
_defaults: &Renderer::Defaults,
|
_defaults: &Renderer::Defaults,
|
||||||
layout: Layout<'_>,
|
layout: Layout<'_>,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
|
_viewport: &Rectangle,
|
||||||
) -> Renderer::Output {
|
) -> Renderer::Output {
|
||||||
let bounds = layout.bounds();
|
let bounds = layout.bounds();
|
||||||
let text_bounds = layout.children().next().unwrap().bounds();
|
let text_bounds = layout.children().next().unwrap().bounds();
|
||||||
|
|
Loading…
Reference in New Issue