From 2760d23f29af18b0299af29a1ce5908a03dfc55a Mon Sep 17 00:00:00 2001 From: ikaros-project Date: Sat, 15 Sep 2018 00:29:31 +0200 Subject: [PATCH] Network view - first step --- Source/WebUI/styling.css | 30 +++++++++++++ Source/WebUI/webui.js | 92 ++++++++++++++++++++++++++++++++++------ 2 files changed, 110 insertions(+), 12 deletions(-) diff --git a/Source/WebUI/styling.css b/Source/WebUI/styling.css index d1b677cda..c1e89eb1f 100644 --- a/Source/WebUI/styling.css +++ b/Source/WebUI/styling.css @@ -369,6 +369,35 @@ div.visible.selected { display: block; } +/* Style for modules */ + +div.module { + position: absolute; + top: 10; + left: 10; + z-index: 200; + width: 101px; + height: 101px; + border: 1px solid black; + border-radius: 10px; + overflow: hidden; + background-color: lightyellow; + cursor: move; + border: none; + border: 1px solid black; + text-align: center; + padding-top:17px; +} + +div.module:hover { + background-color: yellow; +} + +div.group { + border: 5px solid black; + /* background-color: lightgreen; */ +} + /* Style for grid */ @@ -549,3 +578,4 @@ header button:active, aside button:hover { border: 1px solid red; } + diff --git a/Source/WebUI/webui.js b/Source/WebUI/webui.js index c0a364a43..6c77c9ee7 100644 --- a/Source/WebUI/webui.js +++ b/Source/WebUI/webui.js @@ -355,7 +355,7 @@ interaction = { element.handle.onmousedown = interaction.startResize; element.appendChild(element.handle); }, - initViewElement: function (element, data) { // For object in view from IKC file + initViewElement: function (element, data) { // For object in view from IKC file - should be called add widget element.addEventListener('mousedown', interaction.startDrag, true); // capture let constr = webui_widgets.constructors["webui-widget-"+data['class']]; @@ -410,6 +410,10 @@ interaction = { let nodes = document.querySelectorAll(".frame"); for (var i = 0; i < nodes.length; i++) main.removeChild(nodes[i]); + + nodes = document.querySelectorAll(".module"); + for (var i = 0; i < nodes.length; i++) + main.removeChild(nodes[i]); }, generateGrid: function (spacing) { interaction.grid_spacing = spacing; @@ -456,20 +460,82 @@ interaction = { interaction.currentView = controller.views[viewName]; interaction.removeAllObjects(); + let canvas = document.querySelector("#maincanvas"); + let context = canvas.getContext("2d"); + context.clearRect(0, 0, canvas.width, canvas.height); + let main = document.querySelector('main'); - let v = interaction.currentView.objects; - for(let i=0; i0.9) + { + context.beginPath(); + context.moveTo(v[i].x+60, v[i].y+30); + context.lineTo(v[j].x+60, v[j].y+30); + context.stroke(); + } + + return; } }, deselectObject() { @@ -739,6 +805,8 @@ controller = { }, buildViewDictionary: function(group, name) { + controller.views[name+"/"+group.name] = group; + if(group.views) for(i in group.views) controller.views[name+"/"+group.name+"#"+group.views[i].name] = group.views[i]; @@ -893,7 +961,7 @@ controller = { let name = wgt.localName.replace("webui-widget-", ""); s += "\t<"+name+"\n" for(let p in wgt.parameters) - if(wgt.parameters.hasOwnProperty(p) && wgt.parameters[p]) + if(wgt.parameters.hasOwnProperty(p) && wgt.parameters[p]) s += "\t\t"+p+" = \""+wgt.parameters[p]+"\"\n"; s += "\t/>\n\n" }