summaryrefslogtreecommitdiffstats
path: root/core/src/renderer.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-06-29 18:17:18 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-06-29 18:17:18 +0200
commitcdce03cf7f520ef0227aaec4eaed19332197f53b (patch)
treef8524fc4abccb45339580fb72814d3f88052e090 /core/src/renderer.rs
parent98febd9a428f56e28112257adb72ef603fd2ddc5 (diff)
downloadiced-cdce03cf7f520ef0227aaec4eaed19332197f53b.tar.gz
iced-cdce03cf7f520ef0227aaec4eaed19332197f53b.tar.bz2
iced-cdce03cf7f520ef0227aaec4eaed19332197f53b.zip
Revert "Remove `layout` method from `core::Renderer` trait"
This reverts commit 2128472c2a8afcb59927712497c4f613612e9dcc.
Diffstat (limited to 'core/src/renderer.rs')
-rw-r--r--core/src/renderer.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/core/src/renderer.rs b/core/src/renderer.rs
index 1b327e56..7c73d2e4 100644
--- a/core/src/renderer.rs
+++ b/core/src/renderer.rs
@@ -5,13 +5,26 @@ mod null;
#[cfg(debug_assertions)]
pub use null::Null;
-use crate::{Background, BorderRadius, Color, Rectangle, Vector};
+use crate::layout;
+use crate::{Background, BorderRadius, Color, Element, Rectangle, Vector};
/// A component that can be used by widgets to draw themselves on a screen.
pub trait Renderer: Sized {
/// The supported theme of the [`Renderer`].
type Theme;
+ /// Lays out the elements of a user interface.
+ ///
+ /// You should override this if you need to perform any operations before or
+ /// after layouting. For instance, trimming the measurements cache.
+ fn layout<Message>(
+ &mut self,
+ element: &Element<'_, Message, Self>,
+ limits: &layout::Limits,
+ ) -> layout::Node {
+ element.as_widget().layout(self, limits)
+ }
+
/// Draws the primitives recorded in the given closure in a new layer.
///
/// The layer will clip its contents to the provided `bounds`.