Resizable
This commit is contained in:
parent
e4984a9df1
commit
b506939ea8
@ -16,9 +16,10 @@ app.on('ready', () => {
|
||||
backgroundColor: '#000',
|
||||
resizable: true,
|
||||
icon: __dirname + '/icon.ico',
|
||||
frame: process.platform === 'win32',
|
||||
skipTaskbar: process.platform !== 'win32',
|
||||
autoHideMenuBar: process.platform !== 'win32'
|
||||
resizable: true,
|
||||
frame: process.platform !== 'darwin',
|
||||
skipTaskbar: process.platform === 'darwin',
|
||||
autoHideMenuBar: process.platform === 'darwin'
|
||||
})
|
||||
|
||||
app.win.loadURL(`file://${__dirname}/sources/index.html`)
|
||||
|
@ -88,6 +88,9 @@
|
||||
DOTGRID.controller.add("default","Layers","Prev Layer",() => { DOTGRID.tool.selectPrevLayer() });
|
||||
DOTGRID.controller.add("default","Layers","Merge Layers",() => { DOTGRID.tool.merge() },"M");
|
||||
|
||||
DOTGRID.controller.add("default","View","Zoom In",() => { DOTGRID.modZoom(0.25) },"CmdOrCtrl+=")
|
||||
DOTGRID.controller.add("default","View","Zoom Out",() => { DOTGRID.modZoom(-0.25) },"CmdOrCtrl+-")
|
||||
DOTGRID.controller.add("default","View","Zoom Reset",() => { DOTGRID.modZoom(1,true) },"CmdOrCtrl+0")
|
||||
DOTGRID.controller.add("default","View","Color Picker",() => { DOTGRID.picker.start(); },"G");
|
||||
DOTGRID.controller.add("default","View","Toggle Grid",() => { DOTGRID.renderer.toggle(); },"H");
|
||||
DOTGRID.controller.add("default","View","Toggle Interface",() => { DOTGRID.interface.toggle(); },"Tab");
|
||||
|
@ -126,7 +126,7 @@ function Dotgrid () {
|
||||
}
|
||||
}
|
||||
|
||||
this.setSize = function (size = { width: 600, height: 300 }, ui = true, scale = 1) {
|
||||
this.setSize = function (size = { width: 600, height: 300 }, ui = true, scale = window.devicePixelRatio) {
|
||||
size = { width: clamp(step(size.width, 15), 105, 1080), height: clamp(step(size.height, 15), 120, 1080) }
|
||||
|
||||
this.tool.settings.size.width = size.width
|
||||
@ -161,6 +161,17 @@ function Dotgrid () {
|
||||
document.title = `Dotgrid — ${size.width}x${size.height}`
|
||||
}
|
||||
|
||||
this.modZoom = function (mod = 0, set = false) {
|
||||
try {
|
||||
const { webFrame } = require('electron')
|
||||
const currentZoomFactor = webFrame.getZoomFactor()
|
||||
webFrame.setZoomFactor(set ? mod : currentZoomFactor + mod)
|
||||
console.log(window.devicePixelRatio)
|
||||
} catch (err) {
|
||||
console.log('Cannot zoom')
|
||||
}
|
||||
}
|
||||
|
||||
this.setZoom = function (scale) {
|
||||
try {
|
||||
webFrame.setZoomFactor(scale)
|
||||
|
@ -9,7 +9,6 @@ function Theme (_default) {
|
||||
this.el.type = 'text/css'
|
||||
|
||||
this.install = function (host = document.body, callback) {
|
||||
console.log('Theme', 'Installing..')
|
||||
host.appendChild(this.el)
|
||||
this.callback = callback
|
||||
}
|
||||
@ -19,7 +18,7 @@ function Theme (_default) {
|
||||
if (isJson(localStorage.theme)) {
|
||||
const storage = JSON.parse(localStorage.theme)
|
||||
if (validate(storage)) {
|
||||
console.log('Theme', 'Found theme in localStorage!')
|
||||
console.log('Theme', 'Loading localStorage..')
|
||||
this.load(storage)
|
||||
return
|
||||
}
|
||||
@ -30,7 +29,7 @@ function Theme (_default) {
|
||||
this.load = function (data) {
|
||||
const theme = parse(data)
|
||||
if (!validate(theme)) { console.warn('Theme', 'Not a theme', theme); return }
|
||||
console.log('Theme', `Loading theme with background ${theme.background}.`)
|
||||
console.log('Theme', `Load theme, background: ${theme.background}.`)
|
||||
this.el.innerHTML = `:root { --background: ${theme.background}; --f_high: ${theme.f_high}; --f_med: ${theme.f_med}; --f_low: ${theme.f_low}; --f_inv: ${theme.f_inv}; --b_high: ${theme.b_high}; --b_med: ${theme.b_med}; --b_low: ${theme.b_low}; --b_inv: ${theme.b_inv}; }`
|
||||
localStorage.setItem('theme', JSON.stringify(theme))
|
||||
this.active = theme
|
||||
@ -73,7 +72,7 @@ function Theme (_default) {
|
||||
const fs = require('fs')
|
||||
const { dialog, app } = require('electron').remote
|
||||
let paths = dialog.showOpenDialog(app.win, { properties: ['openFile'], filters: [{ name: 'Themes', extensions: ['svg'] }] })
|
||||
if (!paths) { console.log('Nothing to load'); return; }
|
||||
if (!paths) { console.log('Nothing to load'); return }
|
||||
fs.readFile(paths[0], 'utf8', function (err, data) {
|
||||
if (err) throw err
|
||||
themer.load(data)
|
||||
|
@ -10,7 +10,7 @@ function Renderer (dotgrid) {
|
||||
this.context = this.el.getContext('2d')
|
||||
this.showExtras = true
|
||||
|
||||
this.scale = 2
|
||||
this.scale = window.devicePixelRatio
|
||||
|
||||
this.start = function () {
|
||||
this.update()
|
||||
|
Loading…
x
Reference in New Issue
Block a user