Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
egonelbre committed Jun 24, 2012
1 parent 0374a88 commit d569af5
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ main.huds.add(new NetUI());
main.huds.add(new NetMover());
main.huds.add(new WireAdjuster());
main.huds.add(new BiasAdjuster());
main.huds.add(new WireDrawer());

setTimeout(function(){load.click();}, 1000);

Expand Down
51 changes: 51 additions & 0 deletions js/netgui.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,55 @@ BiasAdjuster.methods({
this.selection.setBias(bias);
V.set(this.last, e.scroll);
}
});

function WireDrawer(){
NetAdjuster.call(this);
this.from = {x:0, y:0};
this.to = {x:0, y:0};
}

WireDrawer.inherit(NetAdjuster);
WireDrawer.methods({
render : function(ctx){
if(!this.adjusting)
return;
ctx.lineWidth = 5;
ctx.strokeStyle = "#d44";
ctx.beginPath();
ctx.moveTo(this.from.x, this.from.y);
ctx.lineTo(this.to.x, this.to.y);
ctx.stroke();
},
findItem : function(action, e){
var net = this.getNet(),
keys = Object.keys(net.nodes);
for(var i = keys.length - 1; i >= 0; i -= 1){
var node = net.nodes[keys[i]];
if (node.view == null)
continue;
var p = { x : node.view.pos.x, y : node.view.pos.y + node.view.header + node.view.param };
var inside = V.pointInsideRect(e.scroll, p, {x:node.view.width, y:node.view.param});
if(inside)
return node;
}
},
adjustItem : function(action, e, item){
if(action == "start")
V.set(this.from, e.scroll);
if(action == "move")
V.set(this.to, e.scroll)

if(action == "end"){

}
/*
var bias = this.selection.bias,
dy = e.scroll.y - this.last.y,
dx = e.scroll.x - this.last.x;
bias += dy / 4;
bias += dx / 10;
this.selection.setBias(bias);
V.set(this.last, e.scroll);*/
}
});

0 comments on commit d569af5

Please sign in to comment.