From cb41477afa900d20ac1688e9cd60da84025a2cec Mon Sep 17 00:00:00 2001 From: mix irving Date: Thu, 16 Nov 2017 21:42:46 +1300 Subject: [PATCH] refactor to be tiling window manager friendly --- sources/index.html | 26 ++++++++++++++------------ sources/links/main.css | 30 ++++++++++++++++++------------ sources/scripts/dotgrid.js | 2 +- sources/scripts/interface.js | 4 ++-- 4 files changed, 35 insertions(+), 27 deletions(-) diff --git a/sources/index.html b/sources/index.html index 9507ac3..44462b4 100644 --- a/sources/index.html +++ b/sources/index.html @@ -17,19 +17,21 @@ Dotgrid(Icon) - + document.onkeyup = function myFunction(event){ keyboard.listen(event); }; + document.addEventListener('mousedown', function(e){ dotgrid.mouse_down(e); }, false); + document.addEventListener('mousemove', function(e){ dotgrid.mouse_move(e); }, false); + document.addEventListener('mouseup', function(e){ dotgrid.mouse_up(e);}, false); + + diff --git a/sources/links/main.css b/sources/links/main.css index f78dbf1..8c5c56a 100644 --- a/sources/links/main.css +++ b/sources/links/main.css @@ -1,31 +1,37 @@ body { background:#fff; padding: 5px; font-family: 'input_mono_regular'; -webkit-user-select: none; overflow: hidden;} +#app { + display: flex; + flex-direction: column; + align-items: center; +} -#wrapper { width: calc(100% - 50px); height: calc(100% - 50px); padding: 25px; background: inherit;-webkit-app-region: drag;} -#dotgrid { margin:0px auto; position:fixed; overflow: hidden; padding:10px;-webkit-app-region: no-drag; width:310px !important; height:310px !important; left:35px; top:35px;} -#cursor { opacity: 1; transition: all 50ms; width:8px; height:8px; margin-top:-5px; margin-left:-5px; position:absolute; z-index:25; border-radius:5px; border:1px solid black;} +#wrapper { padding: 25px; background: inherit;-webkit-app-region: drag;} +#dotgrid { margin:0px auto; position:relative; overflow: hidden; padding:10px;-webkit-app-region: no-drag; width:310px !important; height:310px !important; } +#cursor { opacity: 1; transition: all 50ms; width:8px; height:8px; position:absolute; z-index:25; border-radius:5px; border:1px solid black;} #cursor_coord { font-size:10px; z-index: 10000; margin-left:15px; margin-top:-2px;} #cursor_coord.left { margin-left:-110px; text-align: right; width:100px; } -#cursor_from { width:4px; height:4px; background:white; margin-top:-3px; margin-left:-3px; position:absolute; z-index:2500; border-radius:10px; left:-100px;border:1px solid black;} -#cursor_to { width:4px; height:4px; background:white; margin-top:-3px; margin-left:-3px; position:absolute; z-index:2500; border-radius:10px; left:-100px; border:1px solid black;} -#cursor_end { width:4px; height:4px; background:white; margin-top:-3px; margin-left:-3px; position:absolute; z-index:2500; border-radius:10px; left:-100px; border:1px solid black;} +#cursor_from { width:4px; height:4px; background:white; margin-top:2px; margin-left:2px; position:absolute; z-index:2500; border-radius:10px; left:-100px;border:1px solid black;} +#cursor_to { width:4px; height:4px; background:white; margin-top:2px; margin-left:2px; position:absolute; z-index:2500; border-radius:10px; left:-100px; border:1px solid black;} +#cursor_end { width:4px; height:4px; background:white; margin-top:2px; margin-left:2px; position:absolute; z-index:2500; border-radius:10px; left:-100px; border:1px solid black;} -#guide,#widgets { position: absolute;top: 0px;left: 0px; width: 300px;height: 300px;} -#widgets { z-index: 9000 } +#guide,#widgets { position: absolute;width: 300px;height: 300px; margin-left: -5px; margin-top: -5px;} +#widgets { z-index: 9000; margin-left: 0; margin-top: 0; } #render { display: none } .icon { width:25px; height:25px; margin-right:5px; opacity: 1} .icon:hover { cursor: pointer; opacity: 1 } -svg.vector { z-index: 1000;position: relative; left:5px; top:5px; width:300px !important; height:300px !important; } +svg.vector { z-index: 1000;position: relative; left:10px; top:10px; width:300px !important; height:300px !important; } #dotgrid #guide { opacity: 0; transition: all 500ms; } -#dotgrid #widgets { opacity: 0; transition: all 150ms; left: 5px;top: 5px; } +#dotgrid #widgets { opacity: 0; transition: all 150ms; } #dotgrid:hover #guide { opacity: 1 } #dotgrid:hover #widgets { opacity: 1 } -#interface { max-width: 295px;margin: 0px auto;font-size: 11px;line-height: 30px;text-transform: uppercase;margin-top: 15px;-webkit-app-region: no-drag;position: fixed;bottom: 25px;left: 45px; transition: all 50ms;} +#interface { font-size: 11px;line-height: 30px;text-transform: uppercase;-webkit-app-region: no-drag; transition: all 50ms;} #interface svg.inactive { opacity: 0.2 } #interface svg:hover { opacity: 0.5 } +#interface svg.icon:last-child { margin-right: 0 } #interface.hidden { display: none;opacity: 0 } -#interface.visible { display: block; opacity: 1 } \ No newline at end of file +#interface.visible { display: block; opacity: 1 } diff --git a/sources/scripts/dotgrid.js b/sources/scripts/dotgrid.js index 56351be..bf42110 100644 --- a/sources/scripts/dotgrid.js +++ b/sources/scripts/dotgrid.js @@ -51,7 +51,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca this.install = function() { - document.body.appendChild(this.wrapper); + document.getElementById("app").appendChild(this.wrapper); this.wrapper.appendChild(this.element); this.element.appendChild(this.guide.el); this.element.appendChild(this.guide.widgets); diff --git a/sources/scripts/interface.js b/sources/scripts/interface.js index 3eb006a..75f69c8 100644 --- a/sources/scripts/interface.js +++ b/sources/scripts/interface.js @@ -6,7 +6,7 @@ function Interface() this.start = function() { - document.body.appendChild(this.el); + document.getElementById("app").appendChild(this.el); // Interface var html = "" @@ -55,4 +55,4 @@ function Interface() var win = require('electron').remote.getCurrentWindow(); win.setSize(900,this.is_visible ? 420 : 400); } -} \ No newline at end of file +}