Improved resize

This commit is contained in:
Devine Lu Linvega
2019-07-17 11:55:43 +09:00
parent 06bfca5828
commit 0113c3f875
6 changed files with 15 additions and 13 deletions

View File

@@ -4,6 +4,7 @@ function Commander (ronin) {
this._input = document.createElement('textarea')
this._status = document.createElement('div')
this._status.id = 'status'
this.isVisible = true
this.install = function (host) {
this.el.appendChild(this._input)
@@ -22,7 +23,6 @@ function Commander (ronin) {
this.run = (txt = this._input.value) => {
if (txt.indexOf('$') > -1) { ronin.log('Present: $'); return }
ronin.surface.maximize()
const inter = new Lisp(txt, ronin.library)
inter.toPixels()
ronin.always && requestAnimationFrame(() => this.run(txt))
@@ -144,19 +144,19 @@ function Commander (ronin) {
// Display
this.show = function () {
if (ronin.el.className !== '') {
ronin.el.className = ''
}
if (this.isVisible === true) { return }
ronin.el.className = ''
this.isVisible = true
}
this.hide = function () {
if (ronin.el.className !== 'hidden') {
ronin.el.className = 'hidden'
}
if (this.isVisible !== true) { return }
ronin.el.className = 'hidden'
this.isVisible = false
}
this.toggle = function () {
if (ronin.el.className === 'hidden') {
if (this.isVisible !== true) {
this.show()
} else {
this.hide()

View File

@@ -61,7 +61,7 @@ function Ronin () {
}
this.animate = (b = true) => {
if(this.always === b){ return }
if (this.always === b) { return }
this.always = b
this.commander.run()
}

View File

@@ -150,6 +150,7 @@ function Surface (ronin) {
}
this.resize = function (size, fit = false) {
console.log('Surface', `Resize: ${size.w}x${size.h}`)
this.el.width = size.w
this.el.height = size.h
this.el.style.width = size.w + 'px'
@@ -165,7 +166,7 @@ function Surface (ronin) {
this.fitWindow = function (size) {
const win = require('electron').remote.getCurrentWindow()
const pad = { w: 60, h: 60 }
const pad = { w: ronin.commander.isVisible === true ? 400 : 60, h: 60 }
win.setSize(size.w + pad.w, size.h + pad.h, false)
}