Browse Source

app/gfx: fix subtle bug in apply_view/apply_scissor calc where coords are not relative but absolute so use `+ old_view.pos()`

jkds 7 months ago
parent
commit
2494e52558

+ 0 - 2
bin/app/src/app/schema/chat.rs

@@ -239,8 +239,6 @@ pub async fn make(
     prop.set_expr(atom, Role::App, 2, expr::load_var("w")).unwrap();
     prop.set_expr(atom, Role::App, 3, expr::load_var("h")).unwrap();
     node.set_property_u32(atom, Role::App, "z_index", 0).unwrap();
-
-    // Setup the pimpl
     let mut shape = VectorShape::new();
     shape.add_gradient_box(
         expr::const_f32(0.),

+ 2 - 27
bin/app/src/app/schema/mod.rs

@@ -136,6 +136,7 @@ pub async fn make(app: &App, window: SceneNodePtr, i18n_fish: &I18nBabelFish) {
 
     let atom = &mut PropertyAtomicGuard::none();
 
+    /*
     let node = create_shortcut("zoom_out_shortcut");
     node.set_property_str(atom, Role::App, "key", "ctrl+-").unwrap();
     // Not sure what was eating my keys. This is a workaround.
@@ -192,6 +193,7 @@ pub async fn make(app: &App, window: SceneNodePtr, i18n_fish: &I18nBabelFish) {
     app.tasks.lock().unwrap().push(listen_zoom);
     let node = node.setup(|me| Shortcut::new(me)).await;
     window.link(node);
+    */
 
     /*
     let node = create_gesture("zoom_gesture");
@@ -339,33 +341,6 @@ pub async fn make(app: &App, window: SceneNodePtr, i18n_fish: &I18nBabelFish) {
     let content = content.setup(|me| Layer::new(me, app.render_api.clone())).await;
     window.link(content.clone());
 
-    // Debug bg layer cos of content size issues
-    let node = create_vector_art("bgdbg");
-    let prop = node.get_property("rect").unwrap();
-    prop.set_f32(atom, Role::App, 0, 0.).unwrap();
-    prop.set_f32(atom, Role::App, 1, 0.).unwrap();
-    prop.set_expr(atom, Role::App, 2, expr::load_var("w")).unwrap();
-    prop.set_expr(atom, Role::App, 3, expr::load_var("h")).unwrap();
-    node.set_property_u32(atom, Role::App, "z_index", 1).unwrap();
-    let mut shape = VectorShape::new();
-    shape.add_filled_box(
-        expr::const_f32(0.),
-        expr::const_f32(0.),
-        expr::load_var("w"),
-        expr::load_var("h"),
-        [0.8, 0., 0., 0.3],
-    );
-    shape.add_outline(
-        expr::const_f32(0.),
-        expr::const_f32(0.),
-        expr::load_var("w"),
-        expr::load_var("h"),
-        5.,
-        [0., 1., 0., 1.],
-    );
-    let node = node.setup(|me| VectorArt::new(me, shape, app.render_api.clone())).await;
-    content.link(node);
-
     let netlayer_node = create_layer("netstatus_layer");
     let prop = netlayer_node.get_property("rect").unwrap();
     let code = cc.compile("w - NETSTATUS_ICON_SIZE").unwrap();

+ 11 - 11
bin/app/src/app/schema/settings.rs

@@ -231,7 +231,7 @@ pub async fn make(app: &App, window: SceneNodePtr, _ex: ExecutorPtr) {
 
         // Disable visilibity of all relevant window nodes
         // This is needed since for example all chats have a different node name.
-        let windows = sg_root.lookup_node("/window").unwrap().get_children();
+        let windows = sg_root.lookup_node("/window/content").unwrap().get_children();
         let target_substrings = vec!["_chat_layer", "menu_layer", "settings_layer"];
 
         for node in windows.iter() {
@@ -244,7 +244,7 @@ pub async fn make(app: &App, window: SceneNodePtr, _ex: ExecutorPtr) {
         }
 
         // Go back to the dev channel
-        let menu_node = sg_root.lookup_node("/window/dev_chat_layer").unwrap();
+        let menu_node = sg_root.lookup_node("/window/content/dev_chat_layer").unwrap();
         menu_node.set_property_bool(atom, Role::App, "is_visible", true).unwrap();
     };
 
@@ -421,11 +421,11 @@ pub async fn make(app: &App, window: SceneNodePtr, _ex: ExecutorPtr) {
     let search = move || {
         let atom = &mut PropertyAtomicGuard::new();
 
-        let path = "/window/settings_layer/search_input";
+        let path = "/window/content/settings_layer/search_input";
         let node = sg_root3.lookup_node(path.to_string()).unwrap();
         let search_string = node.get_property_str("text").unwrap();
 
-        let path = "/window/settings_layer/search_label";
+        let path = "/window/content/settings_layer/search_label";
         let search_label_node = sg_root3.lookup_node(path.to_string()).unwrap();
 
         if search_string.len() > 0 {
@@ -434,7 +434,7 @@ pub async fn make(app: &App, window: SceneNodePtr, _ex: ExecutorPtr) {
             let _ = search_label_node.set_property_f32(atom, Role::App, "font_size", 16.);
         }
 
-        let path = "/window/settings_layer/settings";
+        let path = "/window/content/settings_layer/settings";
         let node = sg_root3.lookup_node(path.to_string()).unwrap();
         let setting_nodes = node.get_children();
         let mut found_nodes = Vec::new();
@@ -462,7 +462,7 @@ pub async fn make(app: &App, window: SceneNodePtr, _ex: ExecutorPtr) {
 
         // Update the counter
         let counter_text = found_nodes.len().to_string();
-        let path = "/window/settings_layer/search_count";
+        let path = "/window/content/settings_layer/search_count";
         let node = sg_root3.lookup_node(path.to_string()).unwrap();
         let _ = node.set_property_str(atom, Role::App, "text", &counter_text).unwrap();
     };
@@ -1186,13 +1186,13 @@ pub async fn make(app: &App, window: SceneNodePtr, _ex: ExecutorPtr) {
                 let sg_root = sg_root2.clone();
                 let mut lock = cloned_active_setting.lock().unwrap();
 
-                let path = "/window/settings_layer/search_input";
+                let path = "/window/content/settings_layer/search_input";
                 let node = sg_root.lookup_node(path).unwrap();
                 //node.set_property_bool(atom, Role::App, "is_active", false).unwrap();
                 node.set_property_bool(atom, Role::App, "is_focused", false).unwrap();
 
                 let was_active = if let Some(s) = lock.as_ref() {
-                    let path = format!("/window/settings_layer/settings/{}", &s.name);
+                    let path = format!("/window/content/settings_layer/settings/{}", &s.name);
                     let old_node = sg_root.lookup_node(&path).unwrap();
 
                     let _was_active = s.name == setting_clone2.clone().name;
@@ -1501,13 +1501,13 @@ pub async fn make(app: &App, window: SceneNodePtr, _ex: ExecutorPtr) {
         }
     }
 
-    let settings_node = app.sg_root.lookup_node("/window/settings_layer").unwrap();
+    let settings_node = app.sg_root.lookup_node("/window/content/settings_layer").unwrap();
     settings_node.set_property_bool(atom, Role::App, "is_visible", false).unwrap();
 
     // Searchbar results count
-    let node = app.sg_root.lookup_node("/window/settings_layer/settings").unwrap();
+    let node = app.sg_root.lookup_node("/window/content/settings_layer/settings").unwrap();
     let counter_text = node.get_children().len().to_string();
-    let node = app.sg_root.lookup_node("/window/settings_layer/search_count").unwrap();
+    let node = app.sg_root.lookup_node("/window/content/settings_layer/search_count").unwrap();
     node.set_property_str(atom, Role::App, "text", &counter_text).unwrap();
 }
 

+ 3 - 2
bin/app/src/gfx/mod.rs

@@ -591,7 +591,8 @@ struct RenderContext<'a> {
 impl<'a> RenderContext<'a> {
     fn draw(&mut self) {
         if DEBUG_RENDER {
-            d!("RenderContext::draw()");
+            let screen_size = miniquad::window::screen_size();
+            d!("RenderContext::draw() [screen_size={screen_size:?}]");
         }
         if DEBUG_TRAX {
             get_trax().lock().set_curr(0);
@@ -687,7 +688,7 @@ impl<'a> RenderContext<'a> {
                 }
                 GfxDrawInstruction::ApplyView(view) => {
                     // Adjust view relative to cursor
-                    self.view = *view + self.cursor;
+                    self.view = *view + self.cursor + old_view.pos();
 
                     // We could just skip drawing when clipping rect isn't visible
                     // using an is_visible flag.