diff --git a/bin/darkwallet/src/app.rs b/bin/darkwallet/src/app.rs index 3490f575c..edb422b9e 100644 --- a/bin/darkwallet/src/app.rs +++ b/bin/darkwallet/src/app.rs @@ -303,6 +303,51 @@ impl App { sg.link(node_id, layer_node_id).unwrap(); + // Debugging tool + let node_id = create_mesh(&mut sg, "debugtool"); + + let node = sg.get_node_mut(node_id).unwrap(); + let prop = node.get_property("rect").unwrap(); + prop.set_f32(0, 0.).unwrap(); + let code = + vec![Op::Div((Box::new(Op::LoadVar("h".to_string())), Box::new(Op::ConstFloat32(2.))))]; + prop.set_expr(1, code).unwrap(); + let code = vec![Op::LoadVar("w".to_string())]; + prop.set_expr(2, code).unwrap(); + prop.set_f32(3, 5.).unwrap(); + + node.set_property_u32("z_index", 2).unwrap(); + + // Setup the pimpl + let (x1, y1) = (0., 0.); + let (x2, y2) = (1., 1.); + let verts = vec![ + // top left + Vertex { pos: [x1, y1], color: [0., 1., 0., 1.], uv: [0., 0.] }, + // top right + Vertex { pos: [x2, y1], color: [0., 1., 0., 1.], uv: [1., 0.] }, + // bottom left + Vertex { pos: [x1, y2], color: [0., 1., 0., 1.], uv: [0., 1.] }, + // bottom right + Vertex { pos: [x2, y2], color: [0., 1., 0., 1.], uv: [1., 1.] }, + ]; + let indices = vec![0, 2, 1, 1, 2, 3]; + drop(sg); + let pimpl = Mesh::new( + self.ex.clone(), + self.sg.clone(), + node_id, + self.render_api.clone(), + verts, + indices, + ) + .await; + let mut sg = self.sg.lock().await; + let node = sg.get_node_mut(node_id).unwrap(); + node.pimpl = pimpl; + + sg.link(node_id, layer_node_id).unwrap(); + // Create KING GNU! let node_id = create_image(&mut sg, "king"); diff --git a/bin/darkwallet/src/gfx2.rs b/bin/darkwallet/src/gfx2.rs index 98f9f22ba..ac3d5e4ed 100644 --- a/bin/darkwallet/src/gfx2.rs +++ b/bin/darkwallet/src/gfx2.rs @@ -270,8 +270,6 @@ struct RenderContext<'a> { draw_calls: &'a HashMap, uniforms_data: [u8; 128], white_texture: TextureId, - // Used for implementing a push/pop for viewport - current_view: Rectangle, } impl<'a> RenderContext<'a> { @@ -310,7 +308,6 @@ impl<'a> RenderContext<'a> { debug!(target: "gfx", "{}apply_viewport({:?})", ws, view); } prev_view = Some(view.clone()); - self.current_view = view.clone(); self.apply_view(view); } DrawInstruction::ApplyMatrix(model) => { @@ -354,15 +351,14 @@ impl<'a> RenderContext<'a> { for dc in draw_calls { self.draw_call(dc, indent + 1); - } - // Reset view back again - if let Some(view) = prev_view { - if DEBUG_RENDER { - debug!(target: "gfx", "{}reset viewport to {:?}", ws, view); + // Reset view back again in case the draw call changed it + if let Some(view) = &prev_view { + if DEBUG_RENDER { + debug!(target: "gfx", "{}reset viewport to {:?}", ws, view); + } + self.apply_view(view); } - self.apply_view(&view); - self.current_view = view; } } } @@ -827,7 +823,6 @@ impl EventHandler for Stage { draw_calls: &self.draw_calls, uniforms_data, white_texture: self.white_texture, - current_view: default_view, }; render_ctx.draw(); diff --git a/bin/darkwallet/src/ui/editbox.rs b/bin/darkwallet/src/ui/editbox.rs index 25f78f778..f5c5355f3 100644 --- a/bin/darkwallet/src/ui/editbox.rs +++ b/bin/darkwallet/src/ui/editbox.rs @@ -1210,9 +1210,6 @@ impl EditBox { panic!("Node {:?} bad rect property", node); }; - rect.x += parent_rect.x; - rect.y += parent_rect.y; - // draw will recalc this when it's None let render_info = self.regen_mesh(rect.clone()).await; let old_render_info = diff --git a/bin/darkwallet/src/ui/image.rs b/bin/darkwallet/src/ui/image.rs index 4dacede26..2ee340aaa 100644 --- a/bin/darkwallet/src/ui/image.rs +++ b/bin/darkwallet/src/ui/image.rs @@ -152,9 +152,6 @@ impl Image { panic!("Node {:?} bad rect property", node); }; - rect.x += parent_rect.x; - rect.y += parent_rect.x; - // draw will recalc this when it's None let mesh = self.regen_mesh(rect.clone()).await; let old_mesh = std::mem::replace(&mut *self.mesh.lock().unwrap(), Some(mesh.clone())); diff --git a/bin/darkwallet/src/ui/text.rs b/bin/darkwallet/src/ui/text.rs index d4de19789..e7a6ff9eb 100644 --- a/bin/darkwallet/src/ui/text.rs +++ b/bin/darkwallet/src/ui/text.rs @@ -215,9 +215,6 @@ impl Text { panic!("Node {:?} bad rect property", node); }; - rect.x += parent_rect.x; - rect.y += parent_rect.x; - let off_x = rect.x / parent_rect.w; let off_y = rect.y / parent_rect.h; let scale_x = 1. / parent_rect.w;