Skip to content

Commit c415a46

Browse files
committed
Remove layout method from core::Renderer trait
1 parent 2695f1c commit c415a46

File tree

3 files changed

+9
-32
lines changed

3 files changed

+9
-32
lines changed

core/src/renderer.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,13 @@ mod null;
55
#[cfg(debug_assertions)]
66
pub use null::Null;
77

8-
use crate::layout;
9-
use crate::{Background, BorderRadius, Color, Element, Rectangle, Vector};
8+
use crate::{Background, BorderRadius, Color, Rectangle, Vector};
109

1110
/// A component that can be used by widgets to draw themselves on a screen.
1211
pub trait Renderer: Sized {
1312
/// The supported theme of the [`Renderer`].
1413
type Theme;
1514

16-
/// Lays out the elements of a user interface.
17-
///
18-
/// You should override this if you need to perform any operations before or
19-
/// after layouting. For instance, trimming the measurements cache.
20-
fn layout<Message>(
21-
&mut self,
22-
element: &Element<'_, Message, Self>,
23-
limits: &layout::Limits,
24-
) -> layout::Node {
25-
element.as_widget().layout(self, limits)
26-
}
27-
2815
/// Draws the primitives recorded in the given closure in a new layer.
2916
///
3017
/// The layer will clip its contents to the provided `bounds`.

graphics/src/renderer.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@ use crate::backend::{self, Backend};
33
use crate::Primitive;
44

55
use iced_core::image;
6-
use iced_core::layout;
76
use iced_core::renderer;
87
use iced_core::svg;
98
use iced_core::text::{self, Text};
10-
use iced_core::{
11-
Background, Color, Element, Font, Point, Rectangle, Size, Vector,
12-
};
9+
use iced_core::{Background, Color, Font, Point, Rectangle, Size, Vector};
1310

1411
use std::borrow::Cow;
1512
use std::marker::PhantomData;
@@ -84,14 +81,6 @@ impl<B: Backend, T> Renderer<B, T> {
8481
impl<B: Backend, T> iced_core::Renderer for Renderer<B, T> {
8582
type Theme = T;
8683

87-
fn layout<Message>(
88-
&mut self,
89-
element: &Element<'_, Message, Self>,
90-
limits: &layout::Limits,
91-
) -> layout::Node {
92-
element.as_widget().layout(self, limits)
93-
}
94-
9584
fn with_layer(&mut self, bounds: Rectangle, f: impl FnOnce(&mut Self)) {
9685
let current = self.start_layer();
9786

runtime/src/user_interface.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,9 @@ where
9595
let Cache { mut state } = cache;
9696
state.diff(root.as_widget());
9797

98-
let base =
99-
renderer.layout(&root, &layout::Limits::new(Size::ZERO, bounds));
98+
let base = root
99+
.as_widget()
100+
.layout(renderer, &layout::Limits::new(Size::ZERO, bounds));
100101

101102
UserInterface {
102103
root,
@@ -226,8 +227,8 @@ where
226227
if shell.is_layout_invalid() {
227228
let _ = ManuallyDrop::into_inner(manual_overlay);
228229

229-
self.base = renderer.layout(
230-
&self.root,
230+
self.base = self.root.as_widget().layout(
231+
renderer,
231232
&layout::Limits::new(Size::ZERO, self.bounds),
232233
);
233234

@@ -322,8 +323,8 @@ where
322323
}
323324

324325
shell.revalidate_layout(|| {
325-
self.base = renderer.layout(
326-
&self.root,
326+
self.base = self.root.as_widget().layout(
327+
renderer,
327328
&layout::Limits::new(Size::ZERO, self.bounds),
328329
);
329330

0 commit comments

Comments
 (0)