From 8037bddbf7ded3da795dc5acf0450891017eaaed Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Thu, 18 Jul 2019 13:46:14 +0900 Subject: [PATCH] Fixed an issue with resize(), fixes #62 --- desktop/sources/scripts/ronin.js | 1 - desktop/sources/scripts/surface.js | 14 ++++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/desktop/sources/scripts/ronin.js b/desktop/sources/scripts/ronin.js index ea59299..1e229c7 100644 --- a/desktop/sources/scripts/ronin.js +++ b/desktop/sources/scripts/ronin.js @@ -15,7 +15,6 @@ function Ronin () { this.el.id = 'ronin' this.theme = new Theme(defaultTheme) - this.source = new Source(this) this.commander = new Commander(this) this.surface = new Surface(this) diff --git a/desktop/sources/scripts/surface.js b/desktop/sources/scripts/surface.js index a1bd5eb..7945b97 100644 --- a/desktop/sources/scripts/surface.js +++ b/desktop/sources/scripts/surface.js @@ -159,6 +159,8 @@ function Surface (ronin) { } this.resize = function (size, fit = false) { + const frame = this.getFrame() + if (frame.w === size.w && frame.h === size.h) { return } console.log('Surface', `Resize: ${size.w}x${size.h}`) this.el.width = size.w this.el.height = size.h @@ -173,10 +175,14 @@ function Surface (ronin) { } } + this.getFrame = function () { + return { x: 0, y: 0, w: this.el.width, h: this.el.height, t: 'rect' } + } + this.fitWindow = function (size) { const win = require('electron').remote.getCurrentWindow() const pad = { w: ronin.commander.isVisible === true ? 400 : 60, h: 60 } - win.setSize(size.w + pad.w, size.h + pad.h, false) + win.setSize(size.w + pad.w, size.h + pad.h, true) } this.maximize = function () { @@ -191,10 +197,6 @@ function Surface (ronin) { ronin.log(`resize ${f.w}x${f.h}`) } - this.getFrame = function () { - return { x: 0, y: 0, w: this.el.width, h: this.el.height, t: 'rect' } - } - this.getCrop = function (rect) { const newCanvas = document.createElement('canvas') newCanvas.width = rect.w @@ -203,7 +205,7 @@ function Surface (ronin) { return newCanvas } - this.resizeImage = function (src, dst, type = 'image/jpeg', quality = 0.92) { + this.resizeImage = function (src, dst, type = 'image/png', quality = 1.0) { const tmp = new Image() let canvas let context