Просмотр исходного кода

gfx: apply view also will tweak the cursor

darkfi 1 год назад
Родитель
Сommit
07ad9216e7
2 измененных файлов с 8 добавлено и 4 удалено
  1. 8 1
      bin/app/src/gfx/mod.rs
  2. 0 3
      bin/app/src/ui/chatedit.rs

+ 8 - 1
bin/app/src/gfx/mod.rs

@@ -409,6 +409,7 @@ impl<'a> RenderContext<'a> {
     fn draw_call(&mut self, draw_call: &DrawCall, indent: u32) {
         let ws = if DEBUG_RENDER { " ".repeat(indent as usize * 4) } else { String::new() };
 
+        let old_scale = self.scale;
         let old_view = self.view;
         let old_cursor = self.cursor;
 
@@ -431,7 +432,10 @@ impl<'a> RenderContext<'a> {
                     self.apply_model();
                 }
                 DrawInstruction::ApplyView(view) => {
-                    self.view = *view;
+                    // Adjust view relative to cursor
+                    self.view = *view + self.cursor;
+                    // Cursor resets within the view
+                    self.cursor = Point::zero();
                     if DEBUG_RENDER {
                         debug!(target: "gfx",
                             "{ws}apply_view({view:?})  scale={}, view={:?}",
@@ -439,6 +443,7 @@ impl<'a> RenderContext<'a> {
                         );
                     }
                     self.apply_view();
+                    self.apply_model();
                 }
                 DrawInstruction::Draw(mesh) => {
                     if DEBUG_RENDER {
@@ -470,6 +475,8 @@ impl<'a> RenderContext<'a> {
             self.draw_call(dc, indent + 1);
         }
 
+        self.scale = old_scale;
+
         self.cursor = old_cursor;
         self.apply_model();
 

+ 0 - 3
bin/app/src/ui/chatedit.rs

@@ -1035,7 +1035,6 @@ impl ChatEdit {
             self.content_dc_key,
             GfxDrawCall {
                 instrs: vec![
-                    GfxDrawInstruction::ApplyView(rect),
                     GfxDrawInstruction::Move(Point::new(0., -scroll)),
                 ],
                 dcs: vec![self.text_dc_key, self.cursor_dc_key, self.select_dc_key],
@@ -1089,8 +1088,6 @@ impl ChatEdit {
         let padding_bottom = self.padding_bottom();
 
         let mut instrs = vec![];
-        // BUG FIXME SHOULDNT NEED THIS!
-        instrs.push(GfxDrawInstruction::Move(Point::zero()));
         if self.debug.get() {
             let mut rect = self.rect.get();
             rect.x = 0.;