Эх сурвалжийг харах

wallet: janny clean up warnings and comment unused mods

darkfi 2 жил өмнө
parent
commit
7bc9e3c10c

+ 41 - 37
bin/darkwallet/src/app.rs

@@ -1,36 +1,18 @@
-use async_lock::Mutex;
 use async_recursion::async_recursion;
 use futures::{stream::FuturesUnordered, StreamExt};
-use rand::{rngs::OsRng, Rng};
-use std::{
-    sync::{mpsc, Arc, Weak},
-    thread,
-};
+use std::{sync::Arc, thread};
 
 use crate::{
-    chatapp,
-    error::{Error, Result},
-    expr::{Op, SExprMachine, SExprVal},
-    gfx::Rectangle,
-    gfx2::{
-        self, DrawCall, DrawInstruction, DrawMesh, GraphicsEventPublisherPtr, RenderApiPtr, Vertex,
-    },
-    prop::{
-        Property, PropertyBool, PropertyColor, PropertyFloat32, PropertyPtr, PropertyStr,
-        PropertySubType, PropertyType, PropertyUint32,
-    },
-    pubsub::PublisherPtr,
-    scene::{
-        MethodResponseFn, Pimpl, SceneGraph, SceneGraphPtr2, SceneNode, SceneNodeId, SceneNodeInfo,
-        SceneNodeType,
-    },
-    ui::{
-        eval_rect, get_parent_rect, read_rect, DrawUpdate, Mesh, OnModify, RenderLayer,
-        RenderLayerPtr, Stoppable, Window, WindowPtr,
-    },
+    expr::Op,
+    gfx2::{GraphicsEventPublisherPtr, RenderApiPtr, Vertex},
+    prop::{Property, PropertySubType, PropertyType},
+    scene::{Pimpl, SceneGraph, SceneGraphPtr2, SceneNodeId, SceneNodeType},
+    ui::{Mesh, RenderLayer, Stoppable, Window},
 };
 
-pub type AsyncRuntimePtr = Arc<AsyncRuntime>;
+//fn print_type_of<T>(_: &T) {
+//    println!("{}", std::any::type_name::<T>())
+//}
 
 pub struct AsyncRuntime {
     signal: smol::channel::Sender<()>,
@@ -82,7 +64,7 @@ impl AsyncRuntime {
             // Perform cleanup code
             // If not finished in certain amount of time, then just exit
 
-            let mut futures = FuturesUnordered::new();
+            let futures = FuturesUnordered::new();
             for task in tasks {
                 futures.push(task.cancel());
             }
@@ -94,13 +76,11 @@ impl AsyncRuntime {
         }
         let exec_threadpool = std::mem::replace(&mut *self.exec_threadpool.lock().unwrap(), None);
         let exec_threadpool = exec_threadpool.expect("threadpool wasnt started");
-        exec_threadpool.join();
+        exec_threadpool.join().unwrap();
         debug!(target: "app", "Stopped app");
     }
 }
 
-pub type AppPtr = Arc<App>;
-
 pub struct App {
     sg: SceneGraphPtr2,
     ex: Arc<smol::Executor<'static>>,
@@ -175,10 +155,11 @@ impl App {
         self.stop_node(&sg, window_id).await;
     }
 
+    #[async_recursion]
     async fn stop_node(&self, sg: &SceneGraph, node_id: SceneNodeId) {
         let node = sg.get_node(node_id).unwrap();
         for child_inf in node.get_children2() {
-            self.stop_node(sg, child_inf.id);
+            self.stop_node(sg, child_inf.id).await;
         }
         match &node.pimpl {
             Pimpl::Window(win) => win.stop().await,
@@ -191,7 +172,7 @@ impl App {
     async fn make_me_a_schema_plox(&self) {
         // Create a layer called view
         let mut sg = self.sg.lock().await;
-        let layer_node_id = chatapp::create_layer(&mut sg, "view");
+        let layer_node_id = create_layer(&mut sg, "view");
 
         // Customize our layer
         let node = sg.get_node(layer_node_id).unwrap();
@@ -218,7 +199,7 @@ impl App {
         sg.link(node_id, window_id).unwrap();
 
         // Create a bg mesh
-        let node_id = chatapp::create_mesh(&mut sg, "bg");
+        let node_id = create_mesh(&mut sg, "bg");
 
         let node = sg.get_node_mut(node_id).unwrap();
         let prop = node.get_property("rect").unwrap();
@@ -254,7 +235,7 @@ impl App {
         sg.link(node_id, layer_node_id).unwrap();
 
         // Create another mesh
-        let node_id = chatapp::create_mesh(&mut sg, "box");
+        let node_id = create_mesh(&mut sg, "box");
 
         let node = sg.get_node_mut(node_id).unwrap();
         let prop = node.get_property("rect").unwrap();
@@ -298,6 +279,29 @@ impl App {
     }
 }
 
-fn print_type_of<T>(_: &T) {
-    println!("{}", std::any::type_name::<T>())
+pub fn create_layer(sg: &mut SceneGraph, name: &str) -> SceneNodeId {
+    let node = sg.add_node(name, SceneNodeType::RenderLayer);
+    let prop = Property::new("is_visible", PropertyType::Bool, PropertySubType::Null);
+    node.add_property(prop).unwrap();
+
+    let mut prop = Property::new("rect", PropertyType::Float32, PropertySubType::Pixel);
+    prop.set_array_len(4);
+    prop.allow_exprs();
+    node.add_property(prop).unwrap();
+
+    node.id
+}
+
+pub fn create_mesh(sg: &mut SceneGraph, name: &str) -> SceneNodeId {
+    let node = sg.add_node(name, SceneNodeType::RenderMesh);
+
+    let mut prop = Property::new("rect", PropertyType::Float32, PropertySubType::Pixel);
+    prop.set_array_len(4);
+    prop.allow_exprs();
+    node.add_property(prop).unwrap();
+
+    let prop = Property::new("z_index", PropertyType::Uint32, PropertySubType::Null);
+    node.add_property(prop).unwrap();
+
+    node.id
 }

+ 2 - 5
bin/darkwallet/src/chatapp.rs

@@ -1,14 +1,11 @@
-use darkfi_serial::{Decodable, Encodable, SerialDecodable, SerialEncodable};
-use std::sync::mpsc;
+use darkfi_serial::Encodable;
 
 use crate::{
-    error::Result,
     expr::Op,
     gfx::Rectangle,
     prop::{Property, PropertySubType, PropertyType},
-    res::{ResourceId, ResourceManager},
     scene::{
-        MethodResponseFn, Pimpl, SceneGraph, SceneGraphPtr, SceneNode, SceneNodeId, SceneNodeInfo,
+        SceneGraph, SceneNodeId,
         SceneNodeType,
     },
 };

+ 7 - 12
bin/darkwallet/src/chatview.rs

@@ -1,28 +1,23 @@
 use atomic_float::AtomicF32;
-use darkfi_serial::Decodable;
-use log::debug;
-use miniquad::{window, KeyMods, MouseButton, TextureId, UniformType};
+use miniquad::{TextureId, UniformType};
 use std::{
     collections::HashMap,
-    fs::File,
-    io::{BufRead, BufReader, Cursor},
+    io::{BufRead, BufReader},
     path::Path,
     sync::{
-        atomic::{AtomicBool, Ordering},
+        atomic::Ordering,
         Arc, Mutex,
     },
-    time::{Duration, Instant},
 };
 
 use crate::{
-    error::{Error, Result},
+    error::Result,
     gfx::{
-        FreetypeFace, Point, Rectangle, RenderContext, COLOR_BLUE, COLOR_DARKGREY, COLOR_GREEN,
+        FreetypeFace, Point, Rectangle, RenderContext,
         COLOR_RED, COLOR_WHITE,
     },
-    keysym::{KeyCodeAsU16, MouseButtonAsU8},
-    prop::{Property, PropertyBool, PropertyColor, PropertyFloat32, PropertyStr, PropertyUint32},
-    scene::{Pimpl, SceneGraph, SceneNode, SceneNodeId, Slot},
+    prop::PropertyBool,
+    scene::{Pimpl, SceneGraph, SceneNodeId},
     text::{Glyph, TextShaper},
 };
 

+ 3 - 8
bin/darkwallet/src/editbox.rs

@@ -1,26 +1,21 @@
-use darkfi_serial::Decodable;
-use freetype as ft;
 use log::{debug, info};
 use miniquad::{window, KeyMods, MouseButton, TextureId, UniformType};
 use std::{
     collections::HashMap,
-    io::Cursor,
     sync::{
         atomic::{AtomicBool, Ordering},
         Arc, Mutex,
     },
-    time::{Duration, Instant},
+    time::Instant,
 };
 
 use crate::{
     error::{Error, Result},
     gfx::{
-        FreetypeFace, Point, Rectangle, RenderContext, COLOR_BLUE, COLOR_DARKGREY, COLOR_GREEN,
-        COLOR_RED, COLOR_WHITE,
+        FreetypeFace, Point, Rectangle, RenderContext, COLOR_DARKGREY, COLOR_GREEN, COLOR_WHITE,
     },
-    keysym::{KeyCodeAsU16, MouseButtonAsU8},
     prop::{Property, PropertyBool, PropertyColor, PropertyFloat32, PropertyStr, PropertyUint32},
-    scene::{Pimpl, SceneGraph, SceneNode, SceneNodeId, Slot},
+    scene::{Pimpl, SceneGraph, SceneNodeId},
     text::{Glyph, TextShaper},
 };
 

+ 6 - 11
bin/darkwallet/src/expr.rs

@@ -2,13 +2,8 @@ use crate::{
     error::{Error, Result},
     //prop::{Property, PropertySubType, PropertyType, PropertySExprValue},
 };
-use darkfi_serial::{
-    serialize, Decodable, Encodable, ReadExt, SerialDecodable, SerialEncodable, WriteExt,
-};
-use std::{
-    io::{Read, Write},
-    sync::Arc,
-};
+use darkfi_serial::{Decodable, Encodable, ReadExt, SerialDecodable, SerialEncodable};
+use std::io::{Read, Write};
 
 #[derive(Clone, Debug, PartialEq, SerialEncodable, SerialDecodable)]
 pub enum SExprVal {
@@ -29,28 +24,28 @@ impl SExprVal {
 
     fn is_bool(&self) -> bool {
         match self {
-            Self::Bool(v) => true,
+            Self::Bool(_) => true,
             _ => false,
         }
     }
 
     fn is_u32(&self) -> bool {
         match self {
-            Self::Uint32(v) => true,
+            Self::Uint32(_) => true,
             _ => false,
         }
     }
 
     fn is_f32(&self) -> bool {
         match self {
-            Self::Float32(v) => true,
+            Self::Float32(_) => true,
             _ => false,
         }
     }
 
     fn is_str(&self) -> bool {
         match self {
-            Self::Str(v) => true,
+            Self::Str(_) => true,
             _ => false,
         }
     }

+ 3 - 4
bin/darkwallet/src/gfx.rs

@@ -1,6 +1,5 @@
 use darkfi_serial::{Decodable, Encodable, SerialDecodable, SerialEncodable};
 use freetype as ft;
-use log::LevelFilter;
 use miniquad::{
     conf, window, Backend, Bindings, BlendFactor, BlendState, BlendValue, BufferId, BufferLayout,
     BufferSource, BufferType, BufferUsage, Equation, EventHandler, KeyCode, KeyMods, MouseButton,
@@ -12,7 +11,7 @@ use std::{
     collections::HashMap,
     fmt,
     io::Cursor,
-    sync::{mpsc, Arc, Mutex, MutexGuard},
+    sync::{mpsc, Mutex, MutexGuard},
     time::{Duration, Instant},
 };
 
@@ -1072,8 +1071,8 @@ impl<'a> RenderContext<'a> {
                                 let r = (255. * color_r) as u8;
                                 let g = (255. * color_g) as u8;
                                 let b = (255. * color_b) as u8;
-                                let α = ((*coverage as f32) * color_a) as u8;
-                                vec![r, g, b, α]
+                                let a = ((*coverage as f32) * color_a) as u8;
+                                vec![r, g, b, a]
                             })
                             .collect();
                         tdata

+ 75 - 21
bin/darkwallet/src/gfx2.rs

@@ -1,35 +1,21 @@
-use darkfi_serial::{Decodable, Encodable, SerialDecodable, SerialEncodable};
-use freetype as ft;
-use log::{debug, LevelFilter};
+use darkfi_serial::{SerialDecodable, SerialEncodable};
+use log::debug;
 use miniquad::{
     conf, window, Backend, Bindings, BlendFactor, BlendState, BlendValue, BufferId, BufferLayout,
-    BufferSource, BufferType, BufferUsage, Equation, EventHandler, KeyCode, KeyMods, MouseButton,
-    PassAction, Pipeline, PipelineParams, RenderingBackend, ShaderMeta, ShaderSource, TextureId,
-    UniformDesc, UniformType, VertexAttribute, VertexFormat,
+    BufferSource, BufferType, BufferUsage, Equation, EventHandler, KeyCode, KeyMods, PassAction,
+    Pipeline, PipelineParams, RenderingBackend, ShaderMeta, ShaderSource, TextureId, UniformDesc,
+    UniformType, VertexAttribute, VertexFormat,
 };
 use std::{
-    array::IntoIter,
     collections::HashMap,
-    fmt,
-    io::Cursor,
-    sync::{mpsc, Arc, Mutex, MutexGuard},
+    sync::{mpsc, Arc},
     time::{Duration, Instant},
 };
 
 use crate::{
     app::AsyncRuntime,
-    chatview, editbox,
     error::{Error, Result},
-    expr::{SExprMachine, SExprVal},
-    gfx::Rectangle,
-    keysym::{KeyCodeAsStr, MouseButtonAsU8},
-    prop::{Property, PropertySubType, PropertyType},
     pubsub::{Publisher, PublisherPtr, Subscription},
-    res::{ResourceId, ResourceManager},
-    scene::{
-        MethodResponseFn, Pimpl, SceneGraph, SceneGraphPtr, SceneNode, SceneNodeId, SceneNodeInfo,
-        SceneNodeType,
-    },
     shader,
 };
 
@@ -44,6 +30,74 @@ pub struct Vertex {
     pub uv: [f32; 2],
 }
 
+pub struct Point {
+    pub x: f32,
+    pub y: f32,
+}
+
+#[derive(Debug, Clone)]
+pub struct Rectangle {
+    pub x: f32,
+    pub y: f32,
+    pub w: f32,
+    pub h: f32,
+}
+
+impl Rectangle {
+    pub fn zero() -> Self {
+        Self { x: 0., y: 0., w: 0., h: 0. }
+    }
+
+    pub fn from_array(arr: [f32; 4]) -> Self {
+        Self { x: arr[0], y: arr[1], w: arr[2], h: arr[3] }
+    }
+
+    pub fn clip(&self, other: &Self) -> Option<Self> {
+        if other.x + other.w < self.x ||
+            other.x > self.x + self.w ||
+            other.y + other.h < self.y ||
+            other.y > self.y + self.h
+        {
+            return None
+        }
+
+        let mut clipped = other.clone();
+        if clipped.x < self.x {
+            clipped.x = self.x;
+            clipped.w = other.x + other.w - clipped.x;
+        }
+        if clipped.y < self.y {
+            clipped.y = self.y;
+            clipped.h = other.y + other.h - clipped.y;
+        }
+        if clipped.x + clipped.w > self.x + self.w {
+            clipped.w = self.x + self.w - clipped.x;
+        }
+        if clipped.y + clipped.h > self.y + self.h {
+            clipped.h = self.y + self.h - clipped.y;
+        }
+        Some(clipped)
+    }
+
+    pub fn contains(&self, point: &Point) -> bool {
+        self.x <= point.x &&
+            point.x <= self.x + self.w &&
+            self.y <= point.y &&
+            point.y <= self.y + self.h
+    }
+
+    pub fn top_left(&self) -> Point {
+        Point { x: self.x, y: self.y }
+    }
+    pub fn bottom_right(&self) -> Point {
+        Point { x: self.x + self.w, y: self.y + self.h }
+    }
+
+    pub fn includes(&self, child: &Self) -> bool {
+        self.contains(&child.top_left()) && self.contains(&child.bottom_right())
+    }
+}
+
 pub type RenderApiPtr = Arc<RenderApi>;
 
 pub struct RenderApi {
@@ -120,7 +174,7 @@ pub struct DrawMesh {
 
 #[derive(Debug)]
 pub enum DrawInstruction {
-    ApplyViewport(Rectangle<f32>),
+    ApplyViewport(Rectangle),
     ApplyMatrix(glam::Mat4),
     Draw(DrawMesh),
 }

+ 15 - 22
bin/darkwallet/src/main.rs

@@ -6,11 +6,7 @@
 //#![deny(unused_imports)]
 
 use async_lock::Mutex;
-use futures::{stream::FuturesUnordered, StreamExt};
-use std::{
-    sync::{mpsc, Arc},
-    thread,
-};
+use std::sync::{mpsc, Arc};
 
 #[macro_use]
 extern crate log;
@@ -18,30 +14,26 @@ extern crate log;
 use log::LevelFilter;
 
 mod app;
-mod chatapp;
-mod chatview;
-mod editbox;
+//mod chatapp;
+//mod chatview;
+//mod editbox;
 mod error;
 mod expr;
-mod gfx;
+//mod gfx;
 mod gfx2;
 mod keysym;
 mod net;
-mod plugin;
+//mod plugin;
 mod prop;
 mod pubsub;
-mod py;
-mod res;
+//mod py;
+//mod res;
 mod scene;
 mod shader;
-mod text;
+//mod text;
 mod ui;
 
-use crate::{
-    error::{Error, Result},
-    net::ZeroMQAdapter,
-    scene::{SceneGraph, SceneGraphPtr},
-};
+use crate::{net::ZeroMQAdapter, scene::SceneGraph};
 
 #[cfg(target_os = "android")]
 fn panic_hook(panic_info: &std::panic::PanicInfo) {
@@ -73,12 +65,16 @@ fn main() {
     let ex = Arc::new(smol::Executor::new());
     let sg = Arc::new(Mutex::new(SceneGraph::new()));
 
+    let async_runtime = app::AsyncRuntime::new(ex.clone());
+    async_runtime.start();
+
     let sg2 = sg.clone();
     let ex2 = ex.clone();
     let zmq_task = ex.spawn(async {
-        let mut zmq_rpc = ZeroMQAdapter::new(sg2, ex2).await;
+        let zmq_rpc = ZeroMQAdapter::new(sg2, ex2).await;
         zmq_rpc.run().await;
     });
+    async_runtime.push_task(zmq_task);
 
     let (method_req, method_rep) = mpsc::channel();
     // The UI actually needs to be running for this to reply back.
@@ -86,9 +82,6 @@ fn main() {
     let render_api = gfx2::RenderApi::new(method_req);
     let event_pub = gfx2::GraphicsEventPublisher::new();
 
-    let async_runtime = app::AsyncRuntime::new(ex.clone());
-    async_runtime.start();
-
     let app = app::App::new(sg.clone(), ex.clone(), render_api.clone(), event_pub.clone());
     let app_task = ex.spawn(app.start());
     async_runtime.push_task(app_task);

+ 1 - 2
bin/darkwallet/src/net.rs

@@ -2,8 +2,7 @@ use async_lock::Mutex;
 use darkfi_serial::{deserialize, Decodable, Encodable, SerialDecodable, VarInt};
 use std::{
     io::Cursor,
-    sync::{atomic::Ordering, mpsc, Arc},
-    thread,
+    sync::{mpsc, Arc},
 };
 use zeromq::{Socket, SocketRecv, SocketSend};
 

+ 2 - 2
bin/darkwallet/src/plugin.rs

@@ -1,4 +1,4 @@
-use darkfi_serial::{Decodable, Encodable, SerialDecodable, SerialEncodable};
+use darkfi_serial::{Decodable, Encodable};
 use std::{
     io::Cursor,
     sync::{mpsc, Arc, Mutex},
@@ -7,7 +7,7 @@ use std::{
 };
 
 use crate::{
-    error::{Error, Result},
+    error::Result,
     prop::{Property, PropertySubType, PropertyType},
     py::PythonPlugin,
     res::{ResourceId, ResourceManager},

+ 2 - 8
bin/darkwallet/src/prop/mod.rs

@@ -1,14 +1,8 @@
 use crate::error::{Error, Result};
-use atomic_float::AtomicF32;
-use darkfi_serial::{Encodable, SerialDecodable, SerialEncodable, WriteExt};
+use darkfi_serial::{Encodable, SerialDecodable, SerialEncodable};
 use std::{
-    fmt,
     io::Write,
-    str::FromStr,
-    sync::{
-        atomic::{AtomicBool, AtomicU32, Ordering},
-        Arc, Mutex, MutexGuard,
-    },
+    sync::{Arc, Mutex},
 };
 
 use crate::{

+ 1 - 1
bin/darkwallet/src/pubsub.rs

@@ -9,7 +9,7 @@ use crate::error::{Error, Result};
 pub type SubscriptionId = usize;
 
 // Waiting for trait aliases
-trait Piped: Clone + Send + 'static {}
+pub trait Piped: Clone + Send + 'static {}
 impl<T> Piped for T where T: Clone + Send + 'static {}
 
 #[derive(Debug)]

+ 3 - 6
bin/darkwallet/src/py.rs

@@ -1,15 +1,12 @@
-use std::{
-    sync::{Arc, Mutex},
-    thread,
-};
+use std::sync::{Arc, Mutex};
 
 use crate::{
-    error::{Error, Result},
+    error::Result,
     plugin::{
         Category, Plugin, PluginEvent, PluginInstance, PluginInstancePtr, PluginMetadata, SemVer,
         SubCategory,
     },
-    scene::{MethodResponseFn, SceneGraph, SceneGraphPtr, SceneNodeId, SceneNodeType},
+    scene::SceneGraphPtr,
 };
 
 pub struct PythonPlugin {

+ 6 - 15
bin/darkwallet/src/scene.rs

@@ -1,19 +1,10 @@
 use async_channel::Sender;
 use async_lock::Mutex;
-use atomic_float::AtomicF32;
 use darkfi_serial::{SerialDecodable, SerialEncodable};
 use futures::{stream::FuturesUnordered, StreamExt};
-use std::{
-    fmt,
-    str::FromStr,
-    sync::{
-        atomic::{AtomicBool, AtomicU32, Ordering},
-        Arc,
-    },
-};
+use std::{fmt, str::FromStr, sync::Arc};
 
 use crate::{
-    app, chatview, editbox,
     error::{Error, Result},
     prop::{Property, PropertyPtr, PropertyType},
     ui,
@@ -291,7 +282,6 @@ impl SceneGraph {
         // Now update it for all children and parents too
         let parent_ids: Vec<_> = node.parents.iter().map(|parent_inf| parent_inf.id).collect();
         let child_ids: Vec<_> = node.children.iter().map(|child_inf| child_inf.id).collect();
-        drop(node);
 
         'next_parent: for parent_id in parent_ids {
             let parent = self.get_node_mut(parent_id).unwrap();
@@ -522,11 +512,12 @@ impl SceneNode {
     }
     pub async fn trigger(&self, sig_name: &str, data: Vec<u8>) -> Result<()> {
         let sig = self.get_signal(sig_name).ok_or(Error::SignalNotFound)?;
-        let mut futures = FuturesUnordered::new();
+        let futures = FuturesUnordered::new();
         for (_, slot) in sig.get_slots() {
             // Trigger the slot
             futures.push(async {
-                slot.notify.send(data.clone()).await;
+                // Ignore the result
+                let _ = slot.notify.send(data.clone()).await;
             });
         }
         let _: Vec<_> = futures.collect().await;
@@ -636,8 +627,8 @@ pub struct Method {
 
 pub enum Pimpl {
     Null,
-    EditBox(editbox::EditBoxPtr),
-    ChatView(chatview::ChatViewPtr),
+    //EditBox(editbox::EditBoxPtr),
+    //ChatView(chatview::ChatViewPtr),
     Window(ui::WindowPtr),
     RenderLayer(ui::RenderLayerPtr),
     Mesh(ui::Mesh),

+ 0 - 1
bin/darkwallet/src/text.rs

@@ -1,5 +1,4 @@
 use freetype as ft;
-use log::debug;
 
 use crate::gfx::{FreetypeFace, Rectangle};
 

+ 7 - 30
bin/darkwallet/src/ui/layer.rs

@@ -1,29 +1,11 @@
-use async_lock::Mutex;
 use async_recursion::async_recursion;
-use futures::{stream::FuturesUnordered, StreamExt};
 use rand::{rngs::OsRng, Rng};
-use std::{
-    sync::{mpsc, Arc, Weak},
-    thread,
-};
+use std::sync::{Arc, Weak};
 
 use crate::{
-    chatapp,
-    error::{Error, Result},
-    expr::{Op, SExprMachine, SExprVal},
-    gfx::Rectangle,
-    gfx2::{
-        self, DrawCall, DrawInstruction, DrawMesh, GraphicsEventPublisherPtr, RenderApiPtr, Vertex,
-    },
-    prop::{
-        Property, PropertyBool, PropertyColor, PropertyFloat32, PropertyPtr, PropertyStr,
-        PropertySubType, PropertyType, PropertyUint32,
-    },
-    pubsub::PublisherPtr,
-    scene::{
-        MethodResponseFn, Pimpl, SceneGraph, SceneGraphPtr2, SceneNode, SceneNodeId, SceneNodeInfo,
-        SceneNodeType,
-    },
+    gfx2::{DrawCall, DrawInstruction, Rectangle, RenderApiPtr},
+    prop::{PropertyBool, PropertyPtr},
+    scene::{Pimpl, SceneGraph, SceneGraphPtr2, SceneNodeId},
 };
 
 use super::{eval_rect, get_parent_rect, read_rect, DrawUpdate, OnModify, Stoppable};
@@ -33,6 +15,8 @@ pub type RenderLayerPtr = Arc<RenderLayer>;
 pub struct RenderLayer {
     sg: SceneGraphPtr2,
     node_id: SceneNodeId,
+    // Task is dropped at the end of the scope for RenderLayer, hence ending it
+    #[allow(dead_code)]
     tasks: Vec<smol::Task<()>>,
     render_api: RenderApiPtr,
 
@@ -40,8 +24,6 @@ pub struct RenderLayer {
 
     is_visible: PropertyBool,
     rect: PropertyPtr,
-
-    parent_rect: Mutex<Rectangle<f32>>,
 }
 
 impl RenderLayer {
@@ -60,10 +42,6 @@ impl RenderLayer {
         let rect = node.get_property("rect").expect("RenderLayer::rect");
         drop(sg);
 
-        // Monitor for changes to screen_size or scale properties
-        // If so then trigger draw
-        let rect_sub = rect.subscribe_modify();
-
         let self_ = Arc::new_cyclic(|me: &Weak<Self>| {
             let mut on_modify = OnModify::new(ex.clone(), node_name, node_id, me.clone());
             on_modify.when_change(rect.clone(), Self::redraw);
@@ -76,7 +54,6 @@ impl RenderLayer {
                 dc_key: OsRng.gen(),
                 is_visible,
                 rect,
-                parent_rect: Mutex::new(Rectangle { x: 0., y: 0., w: 0., h: 0. }),
             }
         });
 
@@ -100,7 +77,7 @@ impl RenderLayer {
     }
 
     #[async_recursion]
-    pub async fn draw(&self, sg: &SceneGraph, parent_rect: &Rectangle<f32>) -> Option<DrawUpdate> {
+    pub async fn draw(&self, sg: &SceneGraph, parent_rect: &Rectangle) -> Option<DrawUpdate> {
         debug!(target: "app", "RenderLayer::draw()");
         let node = sg.get_node(self.node_id).unwrap();
 

+ 4 - 24
bin/darkwallet/src/ui/mesh.rs

@@ -1,29 +1,9 @@
-use async_lock::Mutex;
-use async_recursion::async_recursion;
-use futures::{stream::FuturesUnordered, StreamExt};
 use rand::{rngs::OsRng, Rng};
-use std::{
-    sync::{mpsc, Arc, Weak},
-    thread,
-};
 
 use crate::{
-    chatapp,
-    error::{Error, Result},
-    expr::{Op, SExprMachine, SExprVal},
-    gfx::Rectangle,
-    gfx2::{
-        self, DrawCall, DrawInstruction, DrawMesh, GraphicsEventPublisherPtr, RenderApiPtr, Vertex,
-    },
-    prop::{
-        Property, PropertyBool, PropertyColor, PropertyFloat32, PropertyPtr, PropertyStr,
-        PropertySubType, PropertyType, PropertyUint32,
-    },
-    pubsub::PublisherPtr,
-    scene::{
-        MethodResponseFn, Pimpl, SceneGraph, SceneGraphPtr2, SceneNode, SceneNodeId, SceneNodeInfo,
-        SceneNodeType,
-    },
+    gfx2::{DrawCall, DrawInstruction, DrawMesh, Rectangle, RenderApiPtr, Vertex},
+    prop::PropertyPtr,
+    scene::{Pimpl, SceneGraph, SceneGraphPtr2, SceneNodeId},
 };
 
 use super::{eval_rect, read_rect, DrawUpdate, Stoppable};
@@ -68,7 +48,7 @@ impl Mesh {
         })
     }
 
-    pub fn draw(&self, sg: &SceneGraph, parent_rect: &Rectangle<f32>) -> Option<DrawUpdate> {
+    pub fn draw(&self, sg: &SceneGraph, parent_rect: &Rectangle) -> Option<DrawUpdate> {
         debug!(target: "app", "Mesh::draw()");
         // Only used for debug messages
         let node = sg.get_node(self.node_id).unwrap();

+ 9 - 27
bin/darkwallet/src/ui/mod.rs

@@ -1,29 +1,11 @@
-use async_lock::Mutex;
-use async_recursion::async_recursion;
-use futures::{stream::FuturesUnordered, StreamExt};
-use rand::{rngs::OsRng, Rng};
-use std::{
-    sync::{mpsc, Arc, Weak},
-    thread,
-};
+use std::sync::{Arc, Weak};
 
 use crate::{
-    chatapp,
     error::{Error, Result},
-    expr::{Op, SExprMachine, SExprVal},
-    gfx::Rectangle,
-    gfx2::{
-        self, DrawCall, DrawInstruction, DrawMesh, GraphicsEventPublisherPtr, RenderApiPtr, Vertex,
-    },
-    prop::{
-        Property, PropertyBool, PropertyColor, PropertyFloat32, PropertyPtr, PropertyStr,
-        PropertySubType, PropertyType, PropertyUint32,
-    },
-    pubsub::PublisherPtr,
-    scene::{
-        MethodResponseFn, Pimpl, SceneGraph, SceneGraphPtr2, SceneNode, SceneNodeId, SceneNodeInfo,
-        SceneNodeType,
-    },
+    expr::{SExprMachine, SExprVal},
+    gfx2::{DrawCall, Rectangle},
+    prop::PropertyPtr,
+    scene::{SceneGraph, SceneNode, SceneNodeId, SceneNodeType},
 };
 
 mod mesh;
@@ -90,7 +72,7 @@ impl<T: Send + Sync + 'static> OnModify<T> {
     }
 }
 
-pub fn eval_rect(rect: PropertyPtr, parent_rect: &Rectangle<f32>) -> Result<()> {
+pub fn eval_rect(rect: PropertyPtr, parent_rect: &Rectangle) -> Result<()> {
     if rect.array_len != 4 {
         return Err(Error::PropertyWrongLen)
     }
@@ -116,7 +98,7 @@ pub fn eval_rect(rect: PropertyPtr, parent_rect: &Rectangle<f32>) -> Result<()>
     Ok(())
 }
 
-pub fn read_rect(rect_prop: PropertyPtr) -> Result<Rectangle<f32>> {
+pub fn read_rect(rect_prop: PropertyPtr) -> Result<Rectangle> {
     if rect_prop.array_len != 4 {
         return Err(Error::PropertyWrongLen)
     }
@@ -132,7 +114,7 @@ pub fn read_rect(rect_prop: PropertyPtr) -> Result<Rectangle<f32>> {
     Ok(Rectangle::from_array(rect))
 }
 
-pub fn get_parent_rect(sg: &SceneGraph, node: &SceneNode) -> Option<Rectangle<f32>> {
+pub fn get_parent_rect(sg: &SceneGraph, node: &SceneNode) -> Option<Rectangle> {
     // read our parent
     if node.parents.is_empty() {
         info!("RenderLayer {:?} has no parents so skipping", node);
@@ -156,7 +138,7 @@ pub fn get_parent_rect(sg: &SceneGraph, node: &SceneNode) -> Option<Rectangle<f3
             let screen_width = screen_size_prop.get_f32(0).unwrap();
             let screen_height = screen_size_prop.get_f32(1).unwrap();
 
-            let parent_rect = Rectangle { x: 0., y: 0., w: screen_width, h: screen_height };
+            let parent_rect = Rectangle::from_array([0., 0., screen_width, screen_height]);
             parent_rect
         }
         SceneNodeType::RenderLayer => {

+ 10 - 28
bin/darkwallet/src/ui/win.rs

@@ -1,37 +1,19 @@
-use async_lock::Mutex;
-use async_recursion::async_recursion;
-use futures::{stream::FuturesUnordered, StreamExt};
-use rand::{rngs::OsRng, Rng};
-use std::{
-    sync::{mpsc, Arc, Weak},
-    thread,
-};
+use std::sync::{Arc, Weak};
 
 use crate::{
-    chatapp,
-    error::{Error, Result},
-    expr::{Op, SExprMachine, SExprVal},
-    gfx::Rectangle,
-    gfx2::{
-        self, DrawCall, DrawInstruction, DrawMesh, GraphicsEventPublisherPtr, RenderApiPtr, Vertex,
-    },
-    prop::{
-        Property, PropertyBool, PropertyColor, PropertyFloat32, PropertyPtr, PropertyStr,
-        PropertySubType, PropertyType, PropertyUint32,
-    },
-    pubsub::PublisherPtr,
-    scene::{
-        MethodResponseFn, Pimpl, SceneGraph, SceneGraphPtr2, SceneNode, SceneNodeId, SceneNodeInfo,
-        SceneNodeType,
-    },
+    gfx2::{DrawCall, GraphicsEventPublisherPtr, Rectangle, RenderApiPtr},
+    prop::PropertyPtr,
+    scene::{Pimpl, SceneGraph, SceneGraphPtr2, SceneNodeId},
 };
 
-use super::{eval_rect, read_rect, DrawUpdate, OnModify, Stoppable};
+use super::{OnModify, Stoppable};
 
 pub type WindowPtr = Arc<Window>;
 
 pub struct Window {
     node_id: SceneNodeId,
+    // Task is dropped at the end of the scope for Window, hence ending it
+    #[allow(dead_code)]
     tasks: Vec<smol::Task<()>>,
     screen_size_prop: PropertyPtr,
     render_api: RenderApiPtr,
@@ -70,8 +52,8 @@ impl Window {
 
                     debug!(target: "app", "Window resized ({w}, {h})");
                     // Now update the properties
-                    screen_size_prop2.set_f32(0, w);
-                    screen_size_prop2.set_f32(1, h);
+                    screen_size_prop2.set_f32(0, w).unwrap();
+                    screen_size_prop2.set_f32(1, h).unwrap();
 
                     let Some(self_) = me2.upgrade() else {
                         // Should not happen
@@ -112,7 +94,7 @@ impl Window {
         let screen_width = self.screen_size_prop.get_f32(0).unwrap();
         let screen_height = self.screen_size_prop.get_f32(1).unwrap();
 
-        let parent_rect = Rectangle { x: 0., y: 0., w: screen_width, h: screen_height };
+        let parent_rect = Rectangle::from_array([0., 0., screen_width, screen_height]);
 
         let mut draw_calls = vec![];
         let mut child_calls = vec![];