Simplify custom_widget example

This commit is contained in:
Héctor Ramón Jiménez 2019-12-07 07:46:31 +01:00
parent 749722fca6
commit f5d3164908

View file

@ -37,14 +37,12 @@ mod circle {
fn layout( fn layout(
&self, &self,
_renderer: &Renderer, _renderer: &Renderer,
limits: &layout::Limits, _limits: &layout::Limits,
) -> layout::Node { ) -> layout::Node {
let size = limits layout::Node::new(Size::new(
.width(Length::Units(self.radius * 2)) f32::from(self.radius) * 2.0,
.height(Length::Units(self.radius * 2)) f32::from(self.radius) * 2.0,
.resolve(Size::ZERO); ))
layout::Node::new(size)
} }
fn hash_layout(&self, state: &mut Hasher) { fn hash_layout(&self, state: &mut Hasher) {
@ -59,11 +57,9 @@ mod circle {
layout: Layout<'_>, layout: Layout<'_>,
_cursor_position: Point, _cursor_position: Point,
) -> (Primitive, MouseCursor) { ) -> (Primitive, MouseCursor) {
let bounds = layout.bounds();
( (
Primitive::Quad { Primitive::Quad {
bounds, bounds: layout.bounds(),
background: Background::Color(Color::BLACK), background: Background::Color(Color::BLACK),
border_radius: self.radius, border_radius: self.radius,
}, },