Przeglądaj źródła

wallet: correct page loading logic

darkfi 2 lat temu
rodzic
commit
e701c72888
1 zmienionych plików z 7 dodań i 3 usunięć
  1. 7 3
      bin/darkwallet/src/ui/chatview.rs

+ 7 - 3
bin/darkwallet/src/ui/chatview.rs

@@ -514,6 +514,7 @@ impl ChatView {
         let font_size = self.font_size.get();
         let font_size = self.font_size.get();
         let line_height = self.line_height.get();
         let line_height = self.line_height.get();
         let baseline = self.baseline.get();
         let baseline = self.baseline.get();
+        let scroll = self.scroll.get();
 
 
         let mut instrs = vec![];
         let mut instrs = vec![];
 
 
@@ -527,7 +528,7 @@ impl ChatView {
         let pages = self.pages2.lock().unwrap().clone();
         let pages = self.pages2.lock().unwrap().clone();
         let mut current_height = descent;
         let mut current_height = descent;
         for page in pages {
         for page in pages {
-            if current_height > rect.h {
+            if current_height > scroll + rect.h {
                 break
                 break
             }
             }
 
 
@@ -557,19 +558,22 @@ impl ChatView {
             // Because we use the scissor, our actual rect is now rect instead of parent_rect
             // Because we use the scissor, our actual rect is now rect instead of parent_rect
             let off_x = 0.;
             let off_x = 0.;
             // This calc decides whether scroll is in terms of pages or pixels
             // This calc decides whether scroll is in terms of pages or pixels
-            let off_y = (self.scroll.get() - current_height + rect.h) / rect.h;
+            let off_y = (scroll - current_height + rect.h) / rect.h;
             let scale_x = 1. / rect.w;
             let scale_x = 1. / rect.w;
             let scale_y = 1. / rect.h;
             let scale_y = 1. / rect.h;
             let model = glam::Mat4::from_translation(glam::Vec3::new(off_x, off_y, 0.)) *
             let model = glam::Mat4::from_translation(glam::Vec3::new(off_x, off_y, 0.)) *
                 glam::Mat4::from_scale(glam::Vec3::new(scale_x, scale_y, 1.));
                 glam::Mat4::from_scale(glam::Vec3::new(scale_x, scale_y, 1.));
 
 
             instrs.push(DrawInstruction::ApplyMatrix(model));
             instrs.push(DrawInstruction::ApplyMatrix(model));
-
             instrs.push(DrawInstruction::Draw(mesh_inf.mesh));
             instrs.push(DrawInstruction::Draw(mesh_inf.mesh));
 
 
             current_height += mesh_inf.px_height;
             current_height += mesh_inf.px_height;
         }
         }
 
 
+        if current_height < scroll + rect.h {
+            debug!(target: "ui::chatview", "draw_cached() loading more pages");
+        }
+
         instrs
         instrs
     }
     }