Revert "Remove layout method from core::Renderer trait"

This reverts commit 2128472c2a.
This commit is contained in:
Héctor Ramón Jiménez 2023-06-29 18:17:18 +02:00
parent 98febd9a42
commit cdce03cf7f
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
3 changed files with 32 additions and 9 deletions

View file

@ -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`.