|
@@ -57,13 +57,14 @@ impl<WC: WindowComponent> WindowState<WC> {
|
|
|
let layout = LinearAccess::new(&self.root_node, self.wc.root_widget().layout_node());
|
|
|
|
|
|
let mut bitmap = self.bitmap.borrow_mut();
|
|
|
- if bitmap.as_ref().map(|v| v.size()) != Some(PixelSize::new(size.width as i32, size.height as i32)) {
|
|
|
+ if bitmap.as_ref().map(|v| v.size())
|
|
|
+ != Some(PixelSize::new(size.width as i32, size.height as i32))
|
|
|
+ {
|
|
|
bitmap.take();
|
|
|
}
|
|
|
|
|
|
- let bitmap = bitmap.get_or_insert_with(|| {
|
|
|
- kahlo::Bitmap::new(size.width as usize, size.height as usize)
|
|
|
- });
|
|
|
+ let bitmap = bitmap
|
|
|
+ .get_or_insert_with(|| kahlo::Bitmap::new(size.width as usize, size.height as usize));
|
|
|
|
|
|
let mut windowbuffer = kahlo::BitmapMut::<kahlo::formats::Bgr32>::new(
|
|
|
unsafe {
|
|
@@ -83,32 +84,42 @@ impl<WC: WindowComponent> WindowState<WC> {
|
|
|
crate::layout::dump_node_tree(LayoutNodeAccess::new(&layout), &mut pre_render_dump);
|
|
|
}
|
|
|
|
|
|
- self.wc.root_widget().render(uih.theme(), &mut bitmap.as_mut());
|
|
|
+ self.wc
|
|
|
+ .root_widget()
|
|
|
+ .render(uih.theme(), &mut bitmap.as_mut());
|
|
|
windowbuffer.copy_from(
|
|
|
bitmap,
|
|
|
PixelBox::from_size(bitmap.size()),
|
|
|
- PixelPoint::zero()
|
|
|
+ PixelPoint::zero(),
|
|
|
);
|
|
|
let after = std::time::Instant::now();
|
|
|
|
|
|
// put the render time on the screen
|
|
|
// we're going to do this the very dumb way for now
|
|
|
- let render_time = format!("time: {:.03}ms", (after - before).as_micros() as f32 / 1000.0);
|
|
|
+ let render_time = format!(
|
|
|
+ "time: {:.03}ms",
|
|
|
+ (after - before).as_micros() as f32 / 1000.0
|
|
|
+ );
|
|
|
let line = uih.theme().make_line(render_time.as_str()).render_line();
|
|
|
|
|
|
windowbuffer.fill_region_masked(
|
|
|
&line,
|
|
|
PixelBox::from_size(line.size()),
|
|
|
- PixelPoint::new(size.width as i32 - line.size().width, size.height as i32 - line.size().height),
|
|
|
+ PixelPoint::new(
|
|
|
+ size.width as i32 - line.size().width,
|
|
|
+ size.height as i32 - line.size().height,
|
|
|
+ ),
|
|
|
uih.theme().foreground,
|
|
|
- kahlo::colour::BlendMode::Simple
|
|
|
+ kahlo::colour::BlendMode::Simple,
|
|
|
);
|
|
|
|
|
|
// now put the pre-render layout dump on the window
|
|
|
// again, we're doing this the dumb way
|
|
|
let mut offset = 0;
|
|
|
for text in pre_render_dump.split("\n") {
|
|
|
- if text.len() == 0 { continue }
|
|
|
+ if text.len() == 0 {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
let line = uih.theme().make_line(text).render_line();
|
|
|
|
|
|
windowbuffer.fill_region_masked(
|
|
@@ -116,7 +127,7 @@ impl<WC: WindowComponent> WindowState<WC> {
|
|
|
PixelBox::from_size(line.size()),
|
|
|
PixelPoint::new(0, offset),
|
|
|
uih.theme().foreground,
|
|
|
- kahlo::colour::BlendMode::Simple
|
|
|
+ kahlo::colour::BlendMode::Simple,
|
|
|
);
|
|
|
|
|
|
offset += line.height() as i32 + 1;
|
|
@@ -154,8 +165,16 @@ impl<WC: WindowComponent> WindowStateAccess for RefCell<WindowState<WC>> {
|
|
|
fn notify_resize(&self, new_size: PixelSize) {
|
|
|
if Some(new_size) != self.borrow().bitmap.borrow().as_ref().map(|v| v.size()) {
|
|
|
self.borrow_mut().bitmap.take();
|
|
|
- self.borrow_mut().wc.root_widget().layout_node().relayout_tree();
|
|
|
- self.borrow_mut().wc.root_widget().layout_node().render_needed();
|
|
|
+ self.borrow_mut()
|
|
|
+ .wc
|
|
|
+ .root_widget()
|
|
|
+ .layout_node()
|
|
|
+ .relayout_tree();
|
|
|
+ self.borrow_mut()
|
|
|
+ .wc
|
|
|
+ .root_widget()
|
|
|
+ .layout_node()
|
|
|
+ .render_needed();
|
|
|
}
|
|
|
}
|
|
|
fn push_event(&self, we: WindowEvent) {
|