[the-board] [ui] Use "area" instead of Thing's state when applicable



commit 23ab970215156e04165dd56bfe2afe43574c9780
Author: Lucas Rocha <lucasr gnome org>
Date:   Fri Jan 14 01:04:14 2011 +0000

    [ui] Use "area" instead of Thing's state when applicable
    
    It's not a good idea to query Thing's state too frequently because it
    might involve heavier operations. Simply use the "area" attribute
    whenever we just want Thing's size and position.

 src/js/ui/page.js |   22 ++++------------------
 1 files changed, 4 insertions(+), 18 deletions(-)
---
diff --git a/src/js/ui/page.js b/src/js/ui/page.js
index 870298e..2b7d914 100644
--- a/src/js/ui/page.js
+++ b/src/js/ui/page.js
@@ -396,15 +396,8 @@ Page.prototype = {
             thing.selected = this._selectedThings.indexOf(thing) >= 0;
 
             if (thing.selected) {
-                let state = thing.onGetState();
-
-                let thingArea = { x1: state.x,
-                                  y1: state.y,
-                                  x2: state.x + state.width,
-                                  y2: state.y + state.height };
-
                 this._dragArea =
-                    this._areaUnion(this._dragArea, thingArea);
+                    this._areaUnion(this._dragArea, thing.area);
             }
         };
 
@@ -418,12 +411,7 @@ Page.prototype = {
 
     _ensureDragArea : function(draggedThing) {
         if (!this._dragArea) {
-            let state = draggedThing.onGetState();
-
-            this._dragArea = { x1: state.x,
-                               y1: state.y,
-                               x2: state.x + state.width,
-                               y2: state.y + state.height };
+            this._dragArea = draggedThing.area;
         }
     },
 
@@ -522,10 +510,8 @@ Page.prototype = {
         this._dragArea.y2 += deltaY;
 
         let moveThing = function(thingToMove) {
-            let state = thingToMove.onGetState();
-
-            let newX = state.x + deltaX;
-            let newY = state.y + deltaY;
+            let newX = thingToMove.area.x1 + deltaX;
+            let newY = thingToMove.area.y1 + deltaY;
 
             thingToMove.setPosition(newX, newY);
         };



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]