no branching allowed

This commit is contained in:
2025-09-25 21:19:47 -04:00
parent 6d829dbe81
commit 06cfeaac6b
2 changed files with 12 additions and 12 deletions

View File

@@ -11,15 +11,15 @@ pub struct Stack {
impl Widget for Stack { impl Widget for Stack {
fn draw(&mut self, painter: &mut Painter) { fn draw(&mut self, painter: &mut Painter) {
for _ in 0..self.offset { for _ in 0..self.offset {
painter.layer = painter.next_layer(); painter.next_layer();
} }
let base = painter.layer; let mut iter = self.children.iter();
for child in &self.children { if let Some(child) = iter.next() {
painter.layer = if painter.layer == base { painter.child_layer();
painter.child_layer() painter.widget(child);
} else { }
painter.next_layer() for child in iter {
}; painter.next_layer();
painter.widget(child); painter.widget(child);
} }
} }

View File

@@ -291,12 +291,12 @@ impl<'a, 'c> Painter<'a, 'c> {
self.ctx.text self.ctx.text
} }
pub fn child_layer(&mut self) -> usize { pub fn child_layer(&mut self) {
self.ctx.layers.child(self.layer) self.layer = self.ctx.layers.child(self.layer);
} }
pub fn next_layer(&mut self) -> usize { pub fn next_layer(&mut self) {
self.ctx.layers.next(self.layer) self.layer = self.ctx.layers.next(self.layer);
} }
} }