Procházet zdrojové kódy

wallet: rename chatview::mouse_* props to chatview::* and remove mouse_scroll_decel since it isn't used anymore.

darkfi před 1 rokem
rodič
revize
8c7bbd2513

+ 1 - 1
bin/darkwallet/gui/api.py

@@ -2,7 +2,7 @@ from collections import namedtuple
 from pydrk import Api, HostApi, PropertyType, PropertySubType, Property, serial
 import zmq
 
-api = Api()
+api = Api(addr="192.168.1.20")
 host = HostApi(api)
 print("Node status:", api.hello())
 

+ 4 - 15
bin/darkwallet/src/app/node.rs

@@ -239,24 +239,13 @@ pub fn create_chatview(
     node.add_property(prop).unwrap();
 
     let mut prop =
-        Property::new("mouse_scroll_start_accel", PropertyType::Float32, PropertySubType::Pixel);
-    prop.set_ui_text("Mouse Scroll Start Acceleration", "Initial acceperation when scrolling");
+        Property::new("scroll_start_accel", PropertyType::Float32, PropertySubType::Pixel);
+    prop.set_ui_text("Scroll Start Acceleration", "Initial acceperation when scrolling");
     prop.set_defaults_f32(vec![4.]).unwrap();
     node.add_property(prop).unwrap();
 
-    let mut prop =
-        Property::new("mouse_scroll_decel", PropertyType::Float32, PropertySubType::Pixel);
-    prop.set_ui_text(
-        "Mouse Scroll Deceleration",
-        "Deceleration factor for mouse scroll acceleration",
-    );
-    prop.set_range_f32(0., 1.);
-    prop.set_defaults_f32(vec![0.5]).unwrap();
-    node.add_property(prop).unwrap();
-
-    let mut prop =
-        Property::new("mouse_scroll_resist", PropertyType::Float32, PropertySubType::Pixel);
-    prop.set_ui_text("Mouse Scroll Resistance", "How quickly scrolling speed is dampened");
+    let mut prop = Property::new("scroll_resist", PropertyType::Float32, PropertySubType::Pixel);
+    prop.set_ui_text("Scroll Resistance", "How quickly scrolling speed is dampened");
     prop.set_range_f32(0., 1.);
     prop.set_defaults_f32(vec![0.9]).unwrap();
     node.add_property(prop).unwrap();

+ 3 - 8
bin/darkwallet/src/app/schema.rs

@@ -658,16 +658,11 @@ pub(super) async fn make(app: &App) {
     //node.set_property_bool(Role::App, "debug", true).unwrap();
 
     #[cfg(target_os = "android")]
-    node.set_property_f32(Role::App, "mouse_scroll_start_accel", 20.).unwrap();
+    node.set_property_f32(Role::App, "scroll_start_accel", 40.).unwrap();
     #[cfg(target_os = "linux")]
-    node.set_property_f32(Role::App, "mouse_scroll_start_accel", 15.).unwrap();
+    node.set_property_f32(Role::App, "scroll_start_accel", 15.).unwrap();
 
-    #[cfg(target_os = "android")]
-    node.set_property_f32(Role::App, "mouse_scroll_decel", 0.99).unwrap();
-    #[cfg(target_os = "linux")]
-    node.set_property_f32(Role::App, "mouse_scroll_decel", 0.5).unwrap();
-
-    node.set_property_f32(Role::App, "mouse_scroll_resist", 0.9).unwrap();
+    node.set_property_f32(Role::App, "scroll_resist", 0.9).unwrap();
 
     let prop = node.get_property("timestamp_color").unwrap();
     prop.set_f32(Role::App, 0, 0.407).unwrap();

+ 11 - 15
bin/darkwallet/src/ui/chatview/mod.rs

@@ -140,9 +140,8 @@ pub struct ChatView {
     z_index: PropertyUint32,
     debug: PropertyBool,
 
-    mouse_scroll_start_accel: PropertyFloat32,
-    mouse_scroll_decel: PropertyFloat32,
-    mouse_scroll_resist: PropertyFloat32,
+    scroll_start_accel: PropertyFloat32,
+    scroll_resist: PropertyFloat32,
 
     // Scroll accel
     motion_cv: Arc<CondVar>,
@@ -183,12 +182,10 @@ impl ChatView {
         let z_index = PropertyUint32::wrap(node, Role::Internal, "z_index", 0).unwrap();
         let debug = PropertyBool::wrap(node, Role::Internal, "debug", 0).unwrap();
 
-        let mouse_scroll_start_accel =
-            PropertyFloat32::wrap(node, Role::Internal, "mouse_scroll_start_accel", 0).unwrap();
-        let mouse_scroll_decel =
-            PropertyFloat32::wrap(node, Role::Internal, "mouse_scroll_decel", 0).unwrap();
-        let mouse_scroll_resist =
-            PropertyFloat32::wrap(node, Role::Internal, "mouse_scroll_resist", 0).unwrap();
+        let scroll_start_accel =
+            PropertyFloat32::wrap(node, Role::Internal, "scroll_start_accel", 0).unwrap();
+        let scroll_resist =
+            PropertyFloat32::wrap(node, Role::Internal, "scroll_resist", 0).unwrap();
         drop(scene_graph);
 
         let self_ = Arc::new_cyclic(|me: &Weak<Self>| {
@@ -309,9 +306,8 @@ impl ChatView {
                 z_index,
                 debug,
 
-                mouse_scroll_start_accel,
-                mouse_scroll_decel,
-                mouse_scroll_resist,
+                scroll_start_accel,
+                scroll_resist,
 
                 motion_cv,
                 speed: AtomicF32::new(0.),
@@ -448,7 +444,7 @@ impl ChatView {
             return
         }
 
-        self.speed.fetch_add(wheel_y * self.mouse_scroll_start_accel.get(), Ordering::Relaxed);
+        self.speed.fetch_add(wheel_y * self.scroll_start_accel.get(), Ordering::Relaxed);
         self.motion_cv.notify();
     }
 
@@ -558,7 +554,7 @@ impl ChatView {
                 //self.speed.fetch_add(speed, Ordering::Relaxed);
                 //debug!(target: "ui::chatview", "speed = {dist} / {time} = {speed}");
 
-                let accel = self.mouse_scroll_start_accel.get() * dist / time;
+                let accel = self.scroll_start_accel.get() * dist / time;
                 let touch_time = touch_info.start_instant.elapsed();
                 debug!(target: "ui::chatview", "accel = {dist} / {time} = {accel},  touch = {touch_time:?}");
                 self.speed.fetch_add(accel, Ordering::Relaxed);
@@ -634,7 +630,7 @@ impl ChatView {
             let mut speed = self.speed.load(Ordering::Relaxed);
 
             // Apply constant decel to speed
-            speed *= self.mouse_scroll_resist.get();
+            speed *= self.scroll_resist.get();
             if speed.abs() < BIG_EPSILON {
                 speed = 0.;
             }