Introduce fill_rectangle to Renderer trait
This commit is contained in:
parent
dfceee99aa
commit
a4f4d83161
3 changed files with 24 additions and 1 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue