diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js index 2345a0c..fc82f7f 100644 --- a/desktop/sources/scripts/library.js +++ b/desktop/sources/scripts/library.js @@ -26,6 +26,11 @@ function Library (ronin) { return rect } + this.resize = (rect) => { + ronin.surface.resize(rect, true) + return rect + } + this.select = (rect = this.frame()) => { return ronin.surface.select(rect) } @@ -132,13 +137,15 @@ function Library (ronin) { return { a, b, t } } + this.text = (x, y, g, s, f = 'Arial', t = 'text') => { + return { x, y, g, s, f, t } + } + this.svg = (d, t = 'svg') => { return { d, t } } - this.text = (x, y, g, s, f = 'Arial', t = 'text') => { - return { x, y, g, s, f, t } - } + // Helpers this.frame = () => { return ronin.surface.getFrame() diff --git a/desktop/sources/scripts/surface.js b/desktop/sources/scripts/surface.js index 0d80be1..d214b8a 100644 --- a/desktop/sources/scripts/surface.js +++ b/desktop/sources/scripts/surface.js @@ -150,7 +150,7 @@ function Surface (ronin) { this.context.drawImage(this.el, a.x, a.y, a.w, a.h, b.x, b.y, b.w, b.h) } - this.resize = function (size) { + this.resize = function (size, fit = false) { this.el.width = size.w this.el.height = size.h this.el.style.width = size.w + 'px' @@ -159,6 +159,15 @@ function Surface (ronin) { this._guide.height = size.h this._guide.style.width = size.w + 'px' this._guide.style.height = size.h + 'px' + if (fit === true) { + this.fitWindow(size) + } + } + + this.fitWindow = function (size) { + const win = require('electron').remote.getCurrentWindow() + const pad = { w: 60, h: 60 } + win.setSize(size.w + pad.w, size.h + pad.h, false) } this.maximize = function () {