Implement basic layer merging for graphics::layer::Stack
This commit is contained in:
parent
95769fcd59
commit
d3e9547079
6 changed files with 122 additions and 17 deletions
|
|
@ -17,8 +17,8 @@ pub struct Layer {
|
|||
pub bounds: Rectangle,
|
||||
pub quads: Vec<(Quad, Background)>,
|
||||
pub primitives: Vec<Item<Primitive>>,
|
||||
pub text: Vec<Item<Text>>,
|
||||
pub images: Vec<Image>,
|
||||
pub text: Vec<Item<Text>>,
|
||||
}
|
||||
|
||||
impl Layer {
|
||||
|
|
@ -284,6 +284,10 @@ impl graphics::Layer for Layer {
|
|||
}
|
||||
}
|
||||
|
||||
fn bounds(&self) -> Rectangle {
|
||||
self.bounds
|
||||
}
|
||||
|
||||
fn flush(&mut self) {}
|
||||
|
||||
fn resize(&mut self, bounds: Rectangle) {
|
||||
|
|
@ -298,6 +302,29 @@ impl graphics::Layer for Layer {
|
|||
self.text.clear();
|
||||
self.images.clear();
|
||||
}
|
||||
|
||||
fn level(&self) -> usize {
|
||||
if !self.text.is_empty() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if !self.images.is_empty() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if !self.primitives.is_empty() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
0
|
||||
}
|
||||
|
||||
fn merge(&mut self, layer: &mut Self) {
|
||||
self.quads.append(&mut layer.quads);
|
||||
self.primitives.append(&mut layer.primitives);
|
||||
self.text.append(&mut layer.text);
|
||||
self.images.append(&mut layer.images);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue