*
This commit is contained in:
@@ -39,8 +39,8 @@ function Client () {
|
||||
window.addEventListener('drop', this.onDrop)
|
||||
|
||||
this.acels.set('File', 'New', 'CmdOrCtrl+N', () => { this.source.new(); this.surface.clear(); this.commander.clear() })
|
||||
this.acels.set('File', 'Save', 'CmdOrCtrl+S', () => { this.source.download('ronin', 'lisp', this.commander._input.value, 'text/plain') })
|
||||
this.acels.set('File', 'Export Image', 'CmdOrCtrl+E', () => { this.source.download('ronin', 'png', this.surface.el.toDataURL('image/png', 1.0), 'image/png') })
|
||||
this.acels.set('File', 'Save', 'CmdOrCtrl+S', () => { this.source.write('ronin', 'lisp', this.commander._input.value, 'text/plain') })
|
||||
this.acels.set('File', 'Export Image', 'CmdOrCtrl+E', () => { this.source.write('ronin', 'png', this.surface.el.toDataURL('image/png', 1.0), 'image/png') })
|
||||
this.acels.set('File', 'Open', 'CmdOrCtrl+O', () => { this.source.open('lisp', this.whenOpen) })
|
||||
|
||||
this.acels.add('Edit', 'undo')
|
||||
|
||||
@@ -37,10 +37,10 @@ function Acels (client) {
|
||||
if ((event.ctrlKey || event.metaKey) && event.shiftKey) {
|
||||
return `CmdOrCtrl+Shift+${accelerator}`
|
||||
}
|
||||
if (event.shiftKey) {
|
||||
if (event.shiftKey && event.key.toUpperCase() !== event.key) {
|
||||
return `Shift+${accelerator}`
|
||||
}
|
||||
if (event.altKey) {
|
||||
if (event.altKey && event.key.length !== 1) {
|
||||
return `Alt+${accelerator}`
|
||||
}
|
||||
if (event.ctrlKey || event.metaKey) {
|
||||
@@ -73,7 +73,7 @@ function Acels (client) {
|
||||
for (const cat in cats) {
|
||||
text += `\n### ${cat}\n\n`
|
||||
for (const item of cats[cat]) {
|
||||
text += item.accelerator ? `- \`${item.accelerator}\`: ${item.info}\n` : ''
|
||||
text += item.accelerator ? `- \`${item.accelerator.replace('`', 'tilde')}\`: ${item.name}\n` : ''
|
||||
}
|
||||
}
|
||||
return text.trim()
|
||||
@@ -83,8 +83,9 @@ function Acels (client) {
|
||||
const cats = this.sort()
|
||||
let text = ''
|
||||
for (const cat in cats) {
|
||||
text += `\n${cat}\n\n`
|
||||
for (const item of cats[cat]) {
|
||||
text += item.accelerator ? `${cat}: ${item.name} | ${item.accelerator}\n` : ''
|
||||
text += item.accelerator ? `${item.name.padEnd(25, '.')} ${item.accelerator}\n` : ''
|
||||
}
|
||||
}
|
||||
return text.trim()
|
||||
@@ -105,13 +106,13 @@ function Acels (client) {
|
||||
submenu: [
|
||||
{ label: 'Download Themes', click: () => { require('electron').shell.openExternal('https://github.com/hundredrabbits/Themes') } },
|
||||
{ label: 'Open Theme', click: () => { client.theme.open() } },
|
||||
{ label: 'Reset Theme', click: () => { client.theme.reset() } }
|
||||
{ label: 'Reset Theme', accelerator: 'CmdOrCtrl+Escape', click: () => { client.theme.reset() } }
|
||||
]
|
||||
},
|
||||
{ label: 'Fullscreen', accelerator: 'CmdOrCtrl+Enter', click: () => { app.toggleFullscreen() } },
|
||||
{ label: 'Hide', accelerator: 'CmdOrCtrl+H', click: () => { app.toggleVisible() } },
|
||||
{ label: 'Toggle Menubar', accelerator: 'Alt+H', click: () => { app.toggleMenubar() } },
|
||||
{ label: 'Inspect', accelerator: 'CmdOrCtrl+.', click: () => { app.inspect() } },
|
||||
{ label: 'Inspect', accelerator: 'CmdOrCtrl+Tab', click: () => { app.inspect() } },
|
||||
{ role: 'quit' }
|
||||
]
|
||||
})
|
||||
|
||||
@@ -18,14 +18,14 @@ function Source (client) {
|
||||
this.cache = {}
|
||||
}
|
||||
|
||||
this.open = (ext, callback) => {
|
||||
this.open = (ext, callback, store = false) => {
|
||||
console.log('Source', 'Open file..')
|
||||
const input = document.createElement('input')
|
||||
input.type = 'file'
|
||||
input.onchange = (e) => {
|
||||
const file = e.target.files[0]
|
||||
if (file.name.indexOf('.' + ext) < 0) { console.warn('Source', `Skipped ${file.name}`); return }
|
||||
this.read(file, callback)
|
||||
this.read(file, callback, store)
|
||||
}
|
||||
input.click()
|
||||
}
|
||||
@@ -37,7 +37,7 @@ function Source (client) {
|
||||
input.setAttribute('multiple', 'multiple')
|
||||
input.onchange = (e) => {
|
||||
for (const file of e.target.files) {
|
||||
if (file.name.indexOf('.' + ext) < 0) { console.warn('Source', `Skipped ${file.name}`); return }
|
||||
if (file.name.indexOf('.' + ext) < 0) { console.warn('Source', `Skipped ${file.name}`); continue }
|
||||
this.read(file, this.store)
|
||||
}
|
||||
}
|
||||
@@ -60,11 +60,12 @@ function Source (client) {
|
||||
|
||||
// I/O
|
||||
|
||||
this.read = (file, callback) => {
|
||||
this.read = (file, callback, store = false) => {
|
||||
const reader = new FileReader()
|
||||
reader.onload = (event) => {
|
||||
const res = event.target.result
|
||||
if (callback) { callback(file, res) }
|
||||
if (store) { this.store(file, res) }
|
||||
}
|
||||
reader.readAsText(file, 'UTF-8')
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
/* global Image */
|
||||
/* global Image */
|
||||
|
||||
function Library (client) {
|
||||
@@ -11,12 +12,9 @@ function Library (client) {
|
||||
return shape || this.rect(0, 0, img.width, img.height)
|
||||
}
|
||||
|
||||
this.export = async (name = 'export', type = 'image/png', quality = 1.0) => { // Exports a graphic file with format.
|
||||
const base64 = client.surface.el.toDataURL(type, quality)
|
||||
const link = document.createElement('a')
|
||||
link.setAttribute('href', base64)
|
||||
link.setAttribute('download', type === 'image/png' ? name + '.png' : name + '.jpg')
|
||||
link.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
|
||||
this.export = async (name = 'ronin', type = 'image/png', quality = 1.0) => { // Exports a graphic file with format.
|
||||
const ext = type === 'image/png' ? name + '.png' : name + '.jpg'
|
||||
client.source.write(name, ext, client.surface.el.toDataURL(type, 1.0), type)
|
||||
}
|
||||
|
||||
// Shapes
|
||||
|
||||
Reference in New Issue
Block a user