Sfoglia il codice sorgente

wallet: implement fractional scaling \o/

darkfi 1 anno fa
parent
commit
d2b1a25f12
2 ha cambiato i file con 10 aggiunte e 5 eliminazioni
  1. 1 1
      bin/darkwallet/src/app/schema.rs
  2. 9 4
      bin/darkwallet/src/gfx/mod.rs

+ 1 - 1
bin/darkwallet/src/app/schema.rs

@@ -127,7 +127,7 @@ pub(super) async fn make_test(app: &App, window: SceneNodePtr) {
     // Create button bg
     let node = create_vector_art("btnbg");
     let prop = node.get_property("rect").unwrap();
-    let code = cc.compile("w - 220").unwrap();
+    let code = cc.compile("w - 210").unwrap();
     prop.set_expr(Role::App, 0, code).unwrap();
     prop.set_f32(Role::App, 1, 10.).unwrap();
     prop.set_f32(Role::App, 2, 200.).unwrap();

+ 9 - 4
bin/darkwallet/src/gfx/mod.rs

@@ -239,7 +239,7 @@ impl<'a> RenderContext<'a> {
     }
 
     fn apply_view(&mut self) {
-        let view = self.view / self.scale;
+        let view = self.view * self.scale;
 
         let (_, screen_height) = window::screen_size();
 
@@ -260,8 +260,8 @@ impl<'a> RenderContext<'a> {
         let off_x = self.cursor.x / self.view.w;
         let off_y = self.cursor.y / self.view.h;
 
-        let scale_w = self.scale / self.view.w;
-        let scale_h = self.scale / self.view.h;
+        let scale_w = 1. / self.view.w;
+        let scale_h = 1. / self.view.h;
 
         let model = glam::Mat4::from_translation(glam::Vec3::new(off_x, off_y, 0.)) *
             glam::Mat4::from_scale(glam::Vec3::new(scale_w, scale_h, 1.));
@@ -281,7 +281,12 @@ impl<'a> RenderContext<'a> {
 
         for instr in &draw_call.instrs {
             match instr {
-                DrawInstruction::SetScale(scale) => self.scale = *scale,
+                DrawInstruction::SetScale(scale) => {
+                    self.scale = *scale;
+                    if DEBUG_RENDER {
+                        debug!(target: "gfx", "{ws}set_scale({scale})");
+                    }
+                }
                 DrawInstruction::Move(off) => {
                     self.cursor += *off;
                     if DEBUG_RENDER {