Use ax() and ay() for drawing... currently the same as x() and y()
authorBenjamin Smedberg <benjamin@smedbergs.us>
Mon, 14 Apr 2008 10:34:52 -0400
changeset 14 92e5cfcae5553de1597e237e271e62e39185f380
parent 13 a74f146eb2de46aede0e6d387b197e5eefd9cca7
child 15 9238af9c1accb616c0367c5227c0d529dbe98a0a
push id1
push userbsmedberg@mozilla.com
push dateMon, 14 Apr 2008 15:21:26 +0000
Use ax() and ay() for drawing... currently the same as x() and y()
www/navigate.js
--- a/www/navigate.js
+++ b/www/navigate.js
@@ -82,16 +82,19 @@ function Revision(node)
 }
 
 Revision.prototype = {
   parents: [],
   children: [],
   _x: null,
   _y: null,
 
+  _atime: null,
+  /* constraint: _ax and _ay are meaningless unless _atime is set */
+
   loaded: function r_loaded()
   {
     return 'rev' in this;
   },
 
   update: function r_update(data)
   {
     if (data.node != this.node)
@@ -128,16 +131,31 @@ Revision.prototype = {
 
   y: function r_y() {
     if (this._y == null)
       throw Error("Revision " + this.node + " is not positioned.");
 
     return this._y;
   },
 
+  /* current animated position */
+  ax: function r_ax() {
+    if (this._atime == null)
+      return this.x();
+
+    return this._ax;
+  },
+
+  ay: function r_ay() {
+    if (this._atime == null)
+      return this.y();
+  
+    return this._ay;
+  },
+
   /* height */
   height: function r_height() {
     if (this.loaded()) {
       return 12 * (3 + this.descSplit.length) + 4;
     }
     
     return 12 + 4;
   },
@@ -337,18 +355,18 @@ function redraw()
     cx.translate(xoffset, 0);
     cx.mozDrawText(t);
     cx.restore();
   }
 
   function drawRev(r)
   {
     let h = r.height();
-    let left = r.x() - REVWIDTH / 2;
-    let top = r.y() - h / 2;
+    let left = r.ax() - REVWIDTH / 2;
+    let top = r.ay() - h / 2;
 
     cx.save();
     // clip the text to the box
     cx.beginPath();
     cx.rect(left, top, REVWIDTH, h);
     cx.stroke();
     cx.clip();
 
@@ -371,24 +389,24 @@ function redraw()
     }
     cx.restore();
   }
 
   function drawArrows(r)
   {
     /* draw all arrows from this rev */
     for each (let child in r.children) {
-      let childx = r.x() + 100;
-      let childy = r.y();
+      let childx = r.ax() + 100;
+      let childy = r.ay();
       if (child.gc) {
-        childx = child.x() - REVWIDTH / 2;
-        childy = child.y();
+        childx = child.ax() - REVWIDTH / 2;
+        childy = child.ay();
       }
       cx.beginPath();
-      cx.moveTo(r.x(), r.y());
+      cx.moveTo(r.ax(), r.ay());
       cx.lineTo(childx, childy);
       cx.stroke();
     }
   }
 
   cx.clearRect(0, 0, gWidth, gHeight);
 
   cx.save();