Skip to content

Commit

Permalink
re #25. Add draw function on ViewTuple.
Browse files Browse the repository at this point in the history
  • Loading branch information
wtholliday committed Jun 29, 2022
1 parent 856e7fb commit 76fbf47
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/viewtuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ pub trait ViewTuple {
fn is_empty(&self) -> bool {
false
} // satisfy clippy

fn draw(&self, id: ViewId, cx: &mut Context, vger: &mut Vger);
}

macro_rules! impl_view_tuple {
Expand All @@ -19,6 +21,32 @@ macro_rules! impl_view_tuple {
fn len(&self) -> usize {
$n
}

fn draw(&self, id: ViewId, cx: &mut Context, vger: &mut Vger) {
$({
let child_id = id.child(&$s);
let layout_box = cx.layout[&child_id];

vger.save();

vger.translate(layout_box.offset);

self.$s.draw(child_id, cx, vger);

if DEBUG_LAYOUT {
let paint = vger.color_paint(CONTROL_BACKGROUND);
vger.stroke_rect(
layout_box.rect.min(),
layout_box.rect.max(),
0.0,
1.0,
paint,
);
}

vger.restore();
})*
}
}
}
}
Expand Down

0 comments on commit 76fbf47

Please sign in to comment.