no branching allowed
This commit is contained in:
@@ -11,15 +11,15 @@ pub struct Stack {
|
||||
impl Widget for Stack {
|
||||
fn draw(&mut self, painter: &mut Painter) {
|
||||
for _ in 0..self.offset {
|
||||
painter.layer = painter.next_layer();
|
||||
painter.next_layer();
|
||||
}
|
||||
let base = painter.layer;
|
||||
for child in &self.children {
|
||||
painter.layer = if painter.layer == base {
|
||||
painter.child_layer()
|
||||
} else {
|
||||
painter.next_layer()
|
||||
};
|
||||
let mut iter = self.children.iter();
|
||||
if let Some(child) = iter.next() {
|
||||
painter.child_layer();
|
||||
painter.widget(child);
|
||||
}
|
||||
for child in iter {
|
||||
painter.next_layer();
|
||||
painter.widget(child);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,12 +291,12 @@ impl<'a, 'c> Painter<'a, 'c> {
|
||||
self.ctx.text
|
||||
}
|
||||
|
||||
pub fn child_layer(&mut self) -> usize {
|
||||
self.ctx.layers.child(self.layer)
|
||||
pub fn child_layer(&mut self) {
|
||||
self.layer = self.ctx.layers.child(self.layer);
|
||||
}
|
||||
|
||||
pub fn next_layer(&mut self) -> usize {
|
||||
self.ctx.layers.next(self.layer)
|
||||
pub fn next_layer(&mut self) {
|
||||
self.layer = self.ctx.layers.next(self.layer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user