summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/edit/htdocs/graph
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-01-16 23:49:31 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-01-16 23:49:31 +0000
commitf90791f2f7b48d7e08ce08f7ead498e1191a96b8 (patch)
treea829513568b183d718280c1a81428adc5637e0ac /sca-cpp/trunk/modules/edit/htdocs/graph
parent999c66e0e2398c38007b437f8c14154b725203a9 (diff)
Add sample widget components and a page to edit them, plus minor user interaction fixes.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1059710 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/modules/edit/htdocs/graph')
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/graph/graph.html26
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/graph/graph.js76
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/graph/index.html9
3 files changed, 68 insertions, 43 deletions
diff --git a/sca-cpp/trunk/modules/edit/htdocs/graph/graph.html b/sca-cpp/trunk/modules/edit/htdocs/graph/graph.html
index 618d638e7d..a7d185da42 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/graph/graph.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/graph/graph.html
@@ -30,9 +30,13 @@
</head>
<body>
+<div>
+<span style="position: absolute; left: 0px; top: 0px"><h2>Palette</h2></span>
+<span style="position: absolute; left: 350px; top: 0px"><h2>App</h2></span>
+</div>
+
<script type="text/javascript">
var editWidget = sca.component("EditWidget");
-var dashboard = sca.reference(editWidget, "dashboard");
var palettes = sca.reference(editWidget, "palettes");
var apps = sca.reference(editWidget, "apps");
@@ -53,46 +57,46 @@ function atomcomposite(doc) {
}
/**
- * Load and display an app.
+ * Get and display an app.
*/
function getapp(name, g) {
if (isNil(name))
return;
apps.get(name, function(doc) {
- graph.append(graph.composite(atomcomposite(doc), graph.mkpath().move(300,0)), g);
+ appendNodes(graph.composite(atomcomposite(doc), graph.mkpath().move(350,0)), g);
});
}
/**
- * Load and display a palette content.
+ * Get and display a palette of components.
*/
-
function getpalette(name, g, bg, palette, gpalettes) {
if (isNil(name))
return;
palettes.get(name, function(doc) {
gpalettes[name] = graph.composite(atomcomposite(doc), graph.mkpath().move(150,0));
- graph.append(gpalettes[name], name == spalette? g : bg);
+ appendNodes(gpalettes[name], name == spalette? g : bg);
});
}
/**
- * Install a palette button and content.
+ * Install a palette, including a button to select the palette, and
+ * the palette content.
*/
function installpalette(name, pos, g, bg, palette, gpalettes) {
var b = graph.mkbutton(name, pos);
- graph.append(mklist(b), g);
+ appendNodes(mklist(b), g);
b.onclick = function() {
// Display the selected palette
spalette = name;
for (var pn in gpalettes)
- graph.append(gpalettes[pn], pn == spalette? g : bg);
+ appendNodes(gpalettes[pn], pn == spalette? g : bg);
}
getpalette(name, g, bg, palette, gpalettes);
}
// Create editor graph area
-var g = graph.mkgraph();
+var g = graph.mkgraph(graph.mkpath().move(0,50));
var bg = graph.mkgroup(graph.mkpath());
// Install the palettes.
@@ -104,7 +108,7 @@ installpalette('operators', graph.mkpath().move(0,150), g, bg, spalette, gpalett
installpalette('social', graph.mkpath().move(0,220), g, bg, spalette, gpalettes);
installpalette('sensors', graph.mkpath().move(0,290), g, bg, spalette, gpalettes);
-// Display the current app
+// Get and display the current app
getapp(appname(), g);
</script>
diff --git a/sca-cpp/trunk/modules/edit/htdocs/graph/graph.js b/sca-cpp/trunk/modules/edit/htdocs/graph/graph.js
index 88a2efd50b..1d3b730539 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/graph/graph.js
+++ b/sca-cpp/trunk/modules/edit/htdocs/graph/graph.js
@@ -223,7 +223,6 @@ if (ui.isIE()) {
var tnode = document.createTextNode(t);
title.appendChild(tnode);
return title;
- return title;
};
/**
@@ -373,9 +372,12 @@ if (ui.isIE()) {
/**
* Make a graph.
*/
- graph.mkgraph = function() {
+ graph.mkgraph = function(pos) {
var div = document.createElement('div');
div.id = 'svgdiv';
+ div.style.position = 'absolute';
+ div.style.left = pos.xpos();
+ div.style.top = pos.ypos();
document.body.appendChild(div);
var svg = document.createElementNS(graph.svgns, 'svg');
@@ -410,23 +412,25 @@ if (ui.isIE()) {
return false;
bringtotop(graph.dragging);
var pos = typeof e.touches != "undefined" ? e.touches[0] : e;
- graph.dragX = pos.clientX;
- graph.dragY = pos.clientY;
+ graph.dragX = pos.screenX;
+ graph.dragY = pos.screenY;
return false;
};
svg.ontouchstart = svg.onmousedown;
- svg.onmouseup = function(e) {
+ window.onmouseup = function(e) {
if (graph.dragging == null)
return false;
graph.dragging = null;
return false;
};
- svg.ontouchend = svg.onmouseup;
+ window.top.onmouseup = window.onmouseup;
+ window.ontouchend = window.onmouseup;
+ window.top.ontouchend = window.onmouseup;
- svg.onmousemove = function(e) {
+ window.onmousemove = function(e) {
if (graph.dragging == null)
return false;
var pmatrix = graph.dragging.parentNode.getCTM();
@@ -434,10 +438,16 @@ if (ui.isIE()) {
var curX = pmatrix != null? (Number(matrix.e) - Number(pmatrix.e)): Number(matrix.e);
var curY = pmatrix != null? (Number(matrix.f) - Number(pmatrix.f)): Number(matrix.f);
var pos = typeof e.touches != "undefined" ? e.touches[0] : e;
- var newX = curX + (pos.clientX - graph.dragX);
- var newY = curY + (pos.clientY - graph.dragY);
- graph.dragX = pos.clientX;
- graph.dragY = pos.clientY;
+ var newX = curX + (pos.screenX - graph.dragX);
+ var newY = curY + (pos.screenY - graph.dragY);
+ if (newX >= 0)
+ graph.dragX = pos.screenX;
+ else
+ newX = 0;
+ if (newY >= 0)
+ graph.dragY = pos.screenY;
+ else
+ newY = 0;
if (graph.dragging.id.substring(0, 8) == 'palette:') {
// Clone an element dragged from the palette
@@ -449,7 +459,9 @@ if (ui.isIE()) {
return false;
};
- svg.ontouchmove = svg.onmousemove;
+ window.top.onmousemove = window.onmousemove;
+ window.ontouchmove = window.onmousemove;
+ window.top.ontouchmove = window.onmousemove;
graph.titlewidthsvg = document.createElementNS(graph.svgns, 'svg');
graph.titlewidthsvg.style.visibility = 'hidden';
@@ -630,7 +642,7 @@ graph.title = function(e) {
graph.tsvcs = function(comp) {
return memo(comp, 'tsvcs', function() {
var svcs = scdl.services(comp);
- var l = filter(function(s) { return scdl.align(s) == 'top'; }, svcs);
+ var l = filter(function(s) { return scdl.align(s) == 'top' && scdl.visible(s) != 'false'; }, svcs);
if (isNil(l))
return mklist();
return mklist(car(l));
@@ -642,7 +654,11 @@ graph.lsvcs = function(comp) {
var svcs = scdl.services(comp);
if (isNil(svcs))
return mklist(mklist("'element","'service","'attribute","'name",scdl.name(comp)));
- var l = filter(function(s) { var a = scdl.align(s); return a == null || a == 'left'; }, svcs);
+ var l = filter(function(s) {
+ var a = scdl.align(s);
+ var v = scdl.visible(s);
+ return (a == null || a == 'left') && v != 'false';
+ }, svcs);
if (isNil(l))
return mklist();
if (!isNil(graph.tsvcs(comp)))
@@ -677,7 +693,7 @@ graph.color = function(comp) {
* Return the height of a reference on the right side of a component.
*/
graph.rrefheight = function(ref, cassoc) {
- return memo(ref, 'height', function() {
+ return memo(ref, 'rheight', function() {
var target = assoc(scdl.target(ref), cassoc);
if (isNil(target))
return 60;
@@ -686,6 +702,18 @@ graph.rrefheight = function(ref, cassoc) {
};
/**
+ * Return the height of a reference on the bottom side of a component.
+ */
+graph.brefheight = function(ref, cassoc) {
+ return memo(ref, 'bheight', function() {
+ var target = assoc(scdl.target(ref), cassoc);
+ if (isNil(target))
+ return 0;
+ return graph.compclosureheight(cadr(target), cassoc);
+ });
+};
+
+/**
* Return the total height of the references on the right side of a component.
*/
graph.rrefsheight = function(refs, cassoc) {
@@ -700,7 +728,7 @@ graph.rrefsheight = function(refs, cassoc) {
graph.brefsheight = function(refs, cassoc) {
if (isNil(refs))
return 0;
- return Math.max(graph.rrefheight(car(refs), cassoc), graph.brefsheight(cdr(refs), cassoc));
+ return Math.max(graph.brefheight(car(refs), cassoc), graph.brefsheight(cdr(refs), cassoc));
};
/**
@@ -870,16 +898,6 @@ graph.buttonpath = function(t) {
};
/**
- * Append a list of graphical elements to a parent.
- */
-graph.append = function(nodes, p) {
- if (isNil(nodes))
- return p;
- p.appendChild(car(nodes));
- return graph.append(cdr(nodes), p);
-};
-
-/**
* Render a composite.
*/
graph.composite = function(compos, pos) {
@@ -927,11 +945,11 @@ graph.composite = function(compos, pos) {
var rrefs = graph.rrefs(comp);
var rpos = graph.mkpath().rmove(graph.compwidth(comp, cassoc), 0);
- graph.append(renderrrefs(rrefs, cassoc, rpos), gcomp);
+ appendNodes(renderrrefs(rrefs, cassoc, rpos), gcomp);
var brefs = graph.brefs(comp);
var bpos = graph.mkpath().rmove(0 , graph.compheight(comp, cassoc));
- graph.append(renderbrefs(brefs, cassoc, bpos), gcomp);
+ appendNodes(renderbrefs(brefs, cassoc, bpos), gcomp);
return mklist(gcomp);
}
@@ -951,7 +969,7 @@ graph.composite = function(compos, pos) {
}
function rendermove(comp, cassoc, pos) {
- return pos.clone().rmove(0, graph.compclosureheight(comp, cassoc) + 20);
+ return pos.clone().rmove(0, graph.compclosureheight(comp, cassoc) + 40);
}
if (isNil(svcs))
diff --git a/sca-cpp/trunk/modules/edit/htdocs/graph/index.html b/sca-cpp/trunk/modules/edit/htdocs/graph/index.html
index 105e240389..c02f7b44d0 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/graph/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/graph/index.html
@@ -19,7 +19,9 @@
<html>
<head>
<title>App Editor</title>
-<meta name="viewport" content="width=device-width user-scalable=no initial-scale=1.0"/>
+<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/>
+<meta name="apple-mobile-web-app-capable" content="yes"/>
+<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
<link rel="stylesheet" type="text/css" href="/ui.css">
<script type="text/javascript" src="/util.js"></script>
<script type="text/javascript" src="/ui.js"></script>
@@ -32,8 +34,6 @@
<div id="graph"></div>
<script type="text/javascript">
-ui.loadwidget('menu', '/menu.html');
-
/**
* Return the current app name.
*/
@@ -41,6 +41,9 @@ function appname() {
return ui.queryParams()['app'];
}
+// Load the menu bar
+ui.loadwidget('menu', '/menu.html?app=' + appname());
+
/**
* Display the editor for an app.
*/