From 9b0bf7611e7ea67da97f51d913d68ec27cf6857a Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sat, 13 Jan 2018 16:24:18 +1300 Subject: [PATCH] Some progress on documentation. --- docs.js | 142 +++++++++++++---------------- main.js | 12 ++- sources/media/vectors/keyboard.svg | 78 ---------------- sources/scripts/dotgrid.js | 28 +++--- 4 files changed, 87 insertions(+), 173 deletions(-) delete mode 100644 sources/media/vectors/keyboard.svg diff --git a/docs.js b/docs.js index f476104..c6f0c0f 100644 --- a/docs.js +++ b/docs.js @@ -1,68 +1,5 @@ function Docs() { - this.layout = [ - {x:0, y:0, width:60, height:60, name:"esc"}, - {x:60, y:0, width:60, height:60, name:"1"}, - {x:120, y:0, width:60, height:60, name:"2"}, - {x:180, y:0, width:60, height:60, name:"3"}, - {x:240, y:0, width:60, height:60, name:"4"}, - {x:300, y:0, width:60, height:60, name:"5"}, - {x:360, y:0, width:60, height:60, name:"6"}, - {x:420, y:0, width:60, height:60, name:"7"}, - {x:480, y:0, width:60, height:60, name:"8"}, - {x:540, y:0, width:60, height:60, name:"9"}, - {x:600, y:0, width:60, height:60, name:"0"}, - {x:660, y:0, width:60, height:60, name:"-"}, - {x:720, y:0, width:60, height:60, name:"+"}, - {x:780, y:0, width:120, height:60, name:"del"}, - {x:0, y:60, width:90, height:60, name:"tab"}, - {x:90, y:60, width:60, height:60, name:"q"}, - {x:150, y:60, width:60, height:60, name:"w"}, - {x:210, y:60, width:60, height:60, name:"e"}, - {x:270, y:60, width:60, height:60, name:"r"}, - {x:330, y:60, width:60, height:60, name:"t"}, - {x:390, y:60, width:60, height:60, name:"y"}, - {x:450, y:60, width:60, height:60, name:"u"}, - {x:510, y:60, width:60, height:60, name:"i"}, - {x:570, y:60, width:60, height:60, name:"o"}, - {x:630, y:60, width:60, height:60, name:"p"}, - {x:690, y:60, width:60, height:60, name:"["}, - {x:750, y:60, width:60, height:60, name:"]"}, - {x:810, y:60, width:90, height:60, name:"|"}, - {x:0, y:120, width:105, height:60, name:"caps"}, - {x:105, y:120, width:60, height:60, name:"a"}, - {x:165, y:120, width:60, height:60, name:"s"}, - {x:225, y:120, width:60, height:60, name:"d"}, - {x:285, y:120, width:60, height:60, name:"f"}, - {x:345, y:120, width:60, height:60, name:"g"}, - {x:405, y:120, width:60, height:60, name:"h"}, - {x:465, y:120, width:60, height:60, name:"j"}, - {x:525, y:120, width:60, height:60, name:"k"}, - {x:585, y:120, width:60, height:60, name:"l"}, - {x:645, y:120, width:60, height:60, name:";"}, - {x:705, y:120, width:60, height:60, name:"'"}, - {x:765, y:120, width:135, height:60, name:"enter"}, - {x:0, y:180, width:135, height:60, name:"shift"}, - {x:135, y:180, width:60, height:60, name:"z"}, - {x:195, y:180, width:60, height:60, name:"x"}, - {x:255, y:180, width:60, height:60, name:"c"}, - {x:315, y:180, width:60, height:60, name:"v"}, - {x:375, y:180, width:60, height:60, name:"b"}, - {x:435, y:180, width:60, height:60, name:"n"}, - {x:495, y:180, width:60, height:60, name:"m"}, - {x:555, y:180, width:60, height:60, name:","}, - {x:615, y:180, width:60, height:60, name:"."}, - {x:675, y:180, width:60, height:60, name:"/"}, - {x:735, y:180, width:165, height:60, name:"capslock"}, - {x:0, y:240, width:90, height:60, name:"ctrl"}, - {x:90, y:240, width:90, height:60, name:"cmd"}, - {x:180, y:240, width:90, height:60, name:"alt"}, - {x:270, y:240, width:270, height:60, name:"space"}, - {x:810, y:240, width:90, height:60, name:"ctrl"}, - {x:720, y:240, width:90, height:60, name:"pn"}, - {x:630, y:240, width:90, height:60, name:"fn"}, - {x:540, y:240, width:90, height:60, name:"alt"}] - this.generate = function(m) { var svg_html = ""; @@ -70,25 +7,13 @@ function Docs() for(id in this.layout){ var key = this.layout[id]; var acc = this.accelerator_for_key(key.name,m); - console.log(acc) svg_html += ``; svg_html += ``; - svg_html += `${key.name.toUpperCase()}`; svg_html += acc && acc.basic ? `${acc.basic}` : ''; svg_html += acc && acc.ctrl ? `${acc.ctrl}` : ''; } - - return `${svg_html}`; + return `${svg_html}`; } this.accelerator_for_key = function(key,menu) @@ -102,9 +27,72 @@ function Docs() acc.ctrl = (option.accelerator.toLowerCase() == ("CmdOrCtrl+"+key).toLowerCase()) ? option.label.toUpperCase().replace("TOGGLE ","").substr(0,8).trim() : acc.ctrl; } } - return acc; } + + this.layout = [ + {x:0, y:0, width:60, height:60, name:"esc"}, + {x:60, y:0, width:60, height:60, name:"1"}, + {x:120, y:0, width:60, height:60, name:"2"}, + {x:180, y:0, width:60, height:60, name:"3"}, + {x:240, y:0, width:60, height:60, name:"4"}, + {x:300, y:0, width:60, height:60, name:"5"}, + {x:360, y:0, width:60, height:60, name:"6"}, + {x:420, y:0, width:60, height:60, name:"7"}, + {x:480, y:0, width:60, height:60, name:"8"}, + {x:540, y:0, width:60, height:60, name:"9"}, + {x:600, y:0, width:60, height:60, name:"0"}, + {x:660, y:0, width:60, height:60, name:"-"}, + {x:720, y:0, width:60, height:60, name:"+"}, + {x:780, y:0, width:120, height:60, name:"backspace"}, + {x:0, y:60, width:90, height:60, name:"tab"}, + {x:90, y:60, width:60, height:60, name:"q"}, + {x:150, y:60, width:60, height:60, name:"w"}, + {x:210, y:60, width:60, height:60, name:"e"}, + {x:270, y:60, width:60, height:60, name:"r"}, + {x:330, y:60, width:60, height:60, name:"t"}, + {x:390, y:60, width:60, height:60, name:"y"}, + {x:450, y:60, width:60, height:60, name:"u"}, + {x:510, y:60, width:60, height:60, name:"i"}, + {x:570, y:60, width:60, height:60, name:"o"}, + {x:630, y:60, width:60, height:60, name:"p"}, + {x:690, y:60, width:60, height:60, name:"["}, + {x:750, y:60, width:60, height:60, name:"]"}, + {x:810, y:60, width:90, height:60, name:"|"}, + {x:0, y:120, width:105, height:60, name:"caps"}, + {x:105, y:120, width:60, height:60, name:"a"}, + {x:165, y:120, width:60, height:60, name:"s"}, + {x:225, y:120, width:60, height:60, name:"d"}, + {x:285, y:120, width:60, height:60, name:"f"}, + {x:345, y:120, width:60, height:60, name:"g"}, + {x:405, y:120, width:60, height:60, name:"h"}, + {x:465, y:120, width:60, height:60, name:"j"}, + {x:525, y:120, width:60, height:60, name:"k"}, + {x:585, y:120, width:60, height:60, name:"l"}, + {x:645, y:120, width:60, height:60, name:";"}, + {x:705, y:120, width:60, height:60, name:"'"}, + {x:765, y:120, width:135, height:60, name:"enter"}, + {x:0, y:180, width:135, height:60, name:"shift"}, + {x:135, y:180, width:60, height:60, name:"z"}, + {x:195, y:180, width:60, height:60, name:"x"}, + {x:255, y:180, width:60, height:60, name:"c"}, + {x:315, y:180, width:60, height:60, name:"v"}, + {x:375, y:180, width:60, height:60, name:"b"}, + {x:435, y:180, width:60, height:60, name:"n"}, + {x:495, y:180, width:60, height:60, name:"m"}, + {x:555, y:180, width:60, height:60, name:","}, + {x:615, y:180, width:60, height:60, name:"."}, + {x:675, y:180, width:60, height:60, name:"/"}, + {x:735, y:180, width:165, height:60, name:"capslock"}, + {x:0, y:240, width:90, height:60, name:"ctrl"}, + {x:90, y:240, width:90, height:60, name:"cmd"}, + {x:180, y:240, width:90, height:60, name:"alt"}, + {x:270, y:240, width:270, height:60, name:"space"}, + {x:810, y:240, width:90, height:60, name:"ctrl"}, + {x:720, y:240, width:90, height:60, name:"pn"}, + {x:630, y:240, width:90, height:60, name:"fn"}, + {x:540, y:240, width:90, height:60, name:"alt"} + ] } module.exports = new Docs(); \ No newline at end of file diff --git a/main.js b/main.js index c8b259d..9069305 100644 --- a/main.js +++ b/main.js @@ -1,4 +1,4 @@ -const {app, BrowserWindow, webFrame, Menu} = require('electron') +const {app, BrowserWindow, webFrame, Menu, dialog} = require('electron') const path = require('path') const url = require('url') const shell = require('electron').shell @@ -27,10 +27,14 @@ app.inject_menu = function(m) app.generate_docs = function(m) { - console.log("Generating docs.."); - var docs = require('./docs.js'); var fs = require('fs'); - fs.writeFile("/Users/VillaMoirai/Desktop/keyboard.svg", docs.generate(m)); + var docs = require('./docs.js'); + + dialog.showSaveDialog((fileName) => { + if (fileName === undefined){ return; } + fileName = fileName.substr(-4,4) != ".svg" ? fileName+".svg" : fileName; + fs.writeFile(fileName, docs.generate(m)); + }); } app.win = null; diff --git a/sources/media/vectors/keyboard.svg b/sources/media/vectors/keyboard.svg deleted file mode 100644 index 3c2b408..0000000 --- a/sources/media/vectors/keyboard.svg +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sources/scripts/dotgrid.js b/sources/scripts/dotgrid.js index ef4aba2..9dcae8a 100644 --- a/sources/scripts/dotgrid.js +++ b/sources/scripts/dotgrid.js @@ -126,42 +126,42 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca this.guide.start(); this.interface.start(); + this.controller.add("default","*","About",() => { require('electron').shell.openExternal('https://github.com/hundredrabbits/Dotgrid'); },"CmdOrCtrl+,"); + this.controller.add("default","*","Fullscreen",() => { app.toggle_fullscreen(); },"CmdOrCtrl+Enter"); + this.controller.add("default","*","Hide",() => { app.toggle_visible(); },"CmdOrCtrl+H"); + this.controller.add("default","*","Inspect",() => { app.inspect(); },"CmdOrCtrl+."); + this.controller.add("default","*","Documentation",() => { dotgrid.controller.docs(); },"CmdOrCtrl+Esc"); this.controller.add("default","*","Reset",() => { dotgrid.reset(); dotgrid.theme.reset(); },"CmdOrCtrl+Backspace"); - this.controller.add("default","*","About Dotgrid",() => { require('electron').shell.openExternal('https://github.com/hundredrabbits/Dotgrid'); },"CmdOrCtrl+,"); - this.controller.add("default","*","Developer Tools",() => { app.inspect(); },"CmdOrCtrl+."); - this.controller.add("default","*","Generate Docs",() => { dotgrid.controller.docs(); },"CmdOrCtrl+Esc"); - this.controller.add("default","*","Toggle Fullscreen",() => { app.toggle_fullscreen(); },"CmdOrCtrl+Enter"); - this.controller.add("default","*","Toggle Visible",() => { app.toggle_visible(); },"CmdOrCtrl+H"); this.controller.add("default","*","Quit",() => { app.exit(); },"CmdOrCtrl+Q"); this.controller.add("default","File","New",() => { dotgrid.new(); },"CmdOrCtrl+N"); this.controller.add("default","File","Open",() => { dotgrid.open(); },"CmdOrCtrl+O"); this.controller.add("default","File","Save",() => { dotgrid.save(); },"CmdOrCtrl+S"); - this.controller.add("default","Edit","Add vertex",() => { dotgrid.add_point(); },"Enter"); + this.controller.add("default","Edit","Vertex",() => { dotgrid.add_point(); },"Enter"); this.controller.add("default","Edit","Undo",() => { dotgrid.undo(); },"CmdOrCtrl+Z"); - this.controller.add("default","Edit","Delete Last",() => { dotgrid.undo(); },"Backspace"); + this.controller.add("default","Edit","Delete",() => { dotgrid.undo(); },"Backspace"); this.controller.add("default","Edit","Move Up",() => { dotgrid.mod_move(new Pos(0,-15)); },"Up"); this.controller.add("default","Edit","Move Down",() => { dotgrid.mod_move(new Pos(0,15)); },"Down"); this.controller.add("default","Edit","Move Left",() => { dotgrid.mod_move(new Pos(-15,0)); },"Left"); this.controller.add("default","Edit","Move Right",() => { dotgrid.mod_move(new Pos(15,0)); },"Right"); - this.controller.add("default","Edit","Deselect All",() => { dotgrid.reset(); },"Esc"); + this.controller.add("default","Edit","Deselect",() => { dotgrid.reset(); },"Esc"); this.controller.add("default","Stroke","Line",() => { dotgrid.draw_line(); },"A"); this.controller.add("default","Stroke","Arc",() => { dotgrid.draw_arc("0,1"); },"S"); - this.controller.add("default","Stroke","Arc Reverse",() => { dotgrid.draw_arc("0,0"); },"D"); + this.controller.add("default","Stroke","Arc Rev",() => { dotgrid.draw_arc("0,0"); },"D"); this.controller.add("default","Stroke","Bezier",() => { dotgrid.draw_bezier(); },"F"); this.controller.add("default","Stroke","Close",() => { dotgrid.draw_close(); },"Z"); - this.controller.add("default","Effect","Increase Thickness",() => { dotgrid.mod_thickness(1) },"]"); - this.controller.add("default","Effect","Decrease Thickness",() => { dotgrid.mod_thickness(-1) },"["); + this.controller.add("default","Effect","Thicker",() => { dotgrid.mod_thickness(1) },"]"); + this.controller.add("default","Effect","Thinner",() => { dotgrid.mod_thickness(-1) },"["); this.controller.add("default","Effect","Linecap",() => { dotgrid.mod_linecap(); },"/"); this.controller.add("default","Effect","Mirror",() => { dotgrid.mod_mirror(); },"Space"); this.controller.add("default","Effect","Fill",() => { dotgrid.toggle_fill(); },"G"); - this.controller.add("default","View","Toggle Tools",() => { dotgrid.interface.toggle(); },";"); - this.controller.add("default","View","Toggle Canvas Size",() => { dotgrid.interface.toggle_zoom(); },":"); - this.controller.add("default","View","Toggle Grid",() => { dotgrid.guide.toggle(); },"H"); + this.controller.add("default","View","Tools",() => { dotgrid.interface.toggle(); },";"); + this.controller.add("default","View","Grid",() => { dotgrid.guide.toggle(); },"H"); + this.controller.add("default","View","Expert",() => { dotgrid.interface.toggle_zoom(); },":"); this.controller.commit();