Introduce fill_rectangle to Renderer trait

This commit is contained in:
Héctor Ramón Jiménez 2021-10-18 14:47:49 +07:00
parent dfceee99aa
commit a4f4d83161
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
3 changed files with 24 additions and 1 deletions

View file

@ -70,6 +70,16 @@ where
});
}
fn fill_rectangle(&mut self, quad: renderer::Quad) {
self.primitives.push(Primitive::Quad {
bounds: quad.bounds,
background: quad.background,
border_radius: quad.border_radius,
border_width: quad.border_width,
border_color: quad.border_color,
});
}
fn clear(&mut self) {
self.primitives.clear();
}

View file

@ -29,7 +29,7 @@ mod null;
pub use null::Null;
use crate::layout;
use crate::{Element, Rectangle, Vector};
use crate::{Background, Color, Element, Rectangle, Vector};
/// A component that can take the state of a user interface and produce an
/// output for its users.
@ -59,4 +59,15 @@ pub trait Renderer: Sized {
);
fn clear(&mut self);
fn fill_rectangle(&mut self, quad: Quad);
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Quad {
pub bounds: Rectangle,
pub background: Background,
pub border_radius: f32,
pub border_width: f32,
pub border_color: Color,
}

View file

@ -37,6 +37,8 @@ impl Renderer for Null {
}
fn clear(&mut self) {}
fn fill_rectangle(&mut self, _quad: renderer::Quad) {}
}
impl renderer::Text for Null {