3 'remoto!stdlib:js/panes/panes/nodeCanvas/node.js',
4 'remoto!stdlib:js/include/utils.js',
5 'remoto!stdlib:js/include/color.js',
6 'remoto!stdlib:js/panes/panes/nodeCanvas/backdrop.css',
12 var svgns =
"http://www.w3.org/2000/svg";
38 function backdrop(_path,_cnv,_attrs,_inputs,_outputs,_base,_icon)
40 this._nodeClass = this._nodeClass ||
backdrop;
42 this._notesWrapper =
null;
45 this._layer =
"backdrop";
54 node.call(
this, _path, _cnv, _attrs,
null,
null, _base ||
"backdrop.rnd", _icon );
67 if (this._root)
return;
70 var p = this._canvas._layers[this._layer];
71 var g = this._root = $( document.createElementNS(svgns,
"g") ).appendTo(p).attr( {
class:
"node" } );
72 g.attr( {
id:
"node-backdrop" } );
77 "vector-effect":
"non-scaling-stroke",
81 var b = this._background = $( document.createElementNS(svgns,
"rect") ).appendTo(g);
87 "vector-effect":
"non-scaling-stroke",
89 "class":
"nodeBackground node-backdrop",
91 "pointer-events":
"none",
94 var h = this._header = $( document.createElementNS(svgns,
"rect") ).appendTo(g);
98 "vector-effect":
"non-scaling-stroke",
102 var l = this._label = $( document.createElementNS(svgns,
"text") ).appendTo(g);
108 "text-anchor":
"middle",
114 var nw = this._notesWrapper = $( document.createElementNS(svgns,
"foreignObject") ).appendTo(g);
122 nw.css( {
"pointer-events":
"none" } );
124 var n = this._notes = $(
"<div class='backdropText'>" ).appendTo(nw);
125 var t = this._attributes.notes.value;
129 var rk = Object.keys(this._resizers);
131 for (var rr=0,i=0; i<rk.length; rr+=90,i++)
133 rc = this._resizers[rk[i]] = $( document.createElementNS(svgns,
"path") ).appendTo(g);
138 d:
"M0 "+resizeSize+
"v-"+resizeSize+
"h"+resizeSize,
139 "class":
"resizeHandle",
142 rc.bind(
"mousedown", this.
resizeCorner.bind(
this,rk[i]));
166 this._diffing =
true;
168 if (
"attributes" in diff)
170 var d = diff[
"attributes"];
176 this._diffing =
false;
191 var b = this._background;
195 var w = this._attributes.box.value.w.value;
196 var h = this._attributes.box.value.h.value;
205 this._boundingBox = a;
207 var rr = this._resizers;
208 rr.TL.attr( {
transform:
"translate(0, 0) rotate(0) " } );
209 rr.TR.attr( {
transform:
"translate("+w+
", 0) rotate(90) " } );
210 rr.BR.attr( {
transform:
"translate("+w+
", "+h+
") rotate(180) " } );
211 rr.BL.attr( {
transform:
"translate(0, "+h+
") rotate(270) " } );
213 var wr = this._notesWrapper;
217 width:Math.max(w-6,0),
218 height:Math.max(h-18,0),
222 var hd = this._header;
231 this._label.attr( {
x:w/2 } );
233 var ns = this._attributes.font.value.size.value;
234 var nc = this._attributes.font.value.color.value;
235 var ff = this._attributes.fontface.value;
238 "font-size": ns+
"px",
239 "line-height": (ns+4)+
"px",
263 var body = $(
"body");
264 var doc = $(document);
265 var
x=0,
y=0,moved =
false;
266 var mw = this._attributes.box.value.w.value;
267 var mh = this._attributes.box.value.h.value;
271 var v = which[0] ===
"T";
272 var h = which[1] ===
"L";
284 body.css(
"cursor",
"pointer");
287 x = e.clientX - click.cx;
288 y = e.clientY - click.cy;
290 x /= THIS._canvas._zoom;
291 y /= THIS._canvas._zoom;
308 b.h.value = Math.abs(b.h.value);
324 b.w.value = Math.abs(b.w.value);
329 THIS._attributes.box.immediateValue = b;
335 doc.bind(
"mousemove", mm);
339 doc.unbind(
"mouseup",mu);
340 doc.unbind(
"mousemove",mm);
341 body.css(
"cursor",
"");
345 doc.bind(
"mouseup", mu);
360 var c = this._canvas;
361 var b = this._background[0].getBBox();
362 b.x = c._x + this.x*c._zoom;
363 b.y = c._y + this.
y*c._zoom;
368 var rr = this._canvas._root[0].ownerSVGElement;
370 var c = rr.getEnclosureList(b,
null);
373 for (var i=0;i<c.length;i++)
376 if (c[i].classList.contains(
"nodeBackground"))
378 n = $( c[i].parentNode ).data(
"node");
398 return (Object.keys(l).length === 0);
413 backdrop.prototype.__defineSetter__(
"color",
function(c)
415 this._attributes.node.value.color.value = c;
416 this._background.attr( {
425 var rc,rk = Object.keys(this._resizers);
426 for (var i=0; i<rk.length; i++)
428 rc = this._resizers[rk[i]];
438 fill: (l > .6) ?
"#000000" :
"#FFFFFF",
448 backdrop.prototype.__defineGetter__(
"color",
function()
450 return this._attributes.node.value.color.value;
459 backdrop.prototype.__defineSetter__(
"notes",
function(n)
461 this._attributes.notes.value = n;
472 backdrop.prototype.__defineGetter__(
"notes",
function()
474 return this._attributes.notes.value;
483 backdrop.prototype.__defineSetter__(
"font",
function(f)
487 this._attributes.font.value = f;
498 backdrop.prototype.__defineGetter__(
"font",
function()
500 return this._attributes.font.value;
509 backdrop.prototype.__defineSetter__(
"fontface",
function(f)
513 this._attributes.fontface.value = f;
524 backdrop.prototype.__defineGetter__(
"fontface",
function()
526 return this._attributes.fontface.value;
535 backdrop.prototype.__defineSetter__(
"selected",
function(s)
537 if (s === this._selected)
543 this._root.attr( {
"class":
"node node-selected"} );
545 this._root.attr( {
"class":
"node"} );
553 return this._selected;
562 backdrop.prototype.__defineGetter__(
"selected",
function()
564 return this._selected;
backdrop(_path, _cnv, _attrs, _icon)
setter color
a setter DOCME
encompassedNodes()
returns the list of nodes encompassed by this backdrop
isEmpty()
returns boolean if this backdrop is empty.
resizeCorner(which, event)
Javascript color object class.
getter luminance
a getter DOCME
setter value
a setter DOCME
getter id
returns the number of milliseconds since midnight January 1, 1970 UTC
getter position
A getter, returns this._position.
node(_path, _cnv, _attrs, _in, _out, _base, _icon)
setter name
a setter DOCME
Utility functions for javascript clients.