From eee1f25d9adb941f9bc0a21a7da5ac9a26781236 Mon Sep 17 00:00:00 2001 From: Jonathan Wilkes <jon.w.wilkes@gmail.com> Date: Tue, 28 Jul 2015 21:07:18 -0400 Subject: [PATCH] put resize_window in pdgui module --- pd/nw/dialog_canvas.html | 16 ++++++++-------- pd/nw/dialog_gatom.html | 1 + pd/nw/dialog_iemgui.html | 16 ++++++++-------- pd/nw/dialog_prefs.html | 22 ++++++++++++---------- pd/nw/pdgui.js | 9 ++++++++- 5 files changed, 37 insertions(+), 27 deletions(-) diff --git a/pd/nw/dialog_canvas.html b/pd/nw/dialog_canvas.html index 4b82396d2..3952adc78 100644 --- a/pd/nw/dialog_canvas.html +++ b/pd/nw/dialog_canvas.html @@ -519,13 +519,13 @@ function cancel() { } } -function resize_window() { - var w = document.body.scrollWidth, - h = document.body.scrollHeight, - win = pdgui.get_dialogwin(pd_object_callback); - win.width = w; - win.height = h; -} +//function resize_window() { +// var w = document.body.scrollWidth, +// h = document.body.scrollHeight, +// win = pdgui.get_dialogwin(pd_object_callback); +// win.width = w; +// win.height = h; +//} function populate_array_form(arrays) { var arrays_select, a_field = document.getElementById('arrays'); @@ -593,7 +593,7 @@ function register_canvas_id(gfxstub, attr_arrays) { // labels and form elements. That makes it more efficient and // snappier, at least on older machines. document.getElementsByClassName('container')[0].style.setProperty('display', 'inline'); - resize_window(); + pdgui.resize_window(pd_object_callback); } function tr_text(id) { diff --git a/pd/nw/dialog_gatom.html b/pd/nw/dialog_gatom.html index 98ea08a67..addb4d238 100644 --- a/pd/nw/dialog_gatom.html +++ b/pd/nw/dialog_gatom.html @@ -224,6 +224,7 @@ function register_canvas_id(gfxstub, attr_array) { // snappier, at least on older machines. document.getElementsByClassName('container')[0] .style.setProperty('display', 'inline'); + pdgui.resize_window(pd_object_callback); } function tr_text(id) { diff --git a/pd/nw/dialog_iemgui.html b/pd/nw/dialog_iemgui.html index ddcc79e8a..1e83d7469 100644 --- a/pd/nw/dialog_iemgui.html +++ b/pd/nw/dialog_iemgui.html @@ -476,13 +476,13 @@ function cancel() { pdgui.pdsend(pd_object_callback + " cancel"); } -function resize_window() { - var w = document.body.scrollWidth, - h = document.body.scrollHeight, - win = pdgui.get_dialogwin(pd_object_callback); - win.width = w; - win.height = h; -} +//function resize_window() { +// var w = document.body.scrollWidth, +// h = document.body.scrollHeight, +// win = pdgui.get_dialogwin(pd_object_callback); +// win.width = w; +// win.height = h; +//} // This gets called from the nw_create_window function in index.html // It provides us with our window id from the C side. Once we have it @@ -504,7 +504,7 @@ function register_canvas_id(gfxstub, attr_array) { // labels and form elements. That makes it more efficient and // snappier, at least on older machines. document.getElementsByClassName('container')[0].style.setProperty('display', 'inline'); - resize_window(); + pdgui.resize_window(pd_object_callback); } function tr_text(id) { diff --git a/pd/nw/dialog_prefs.html b/pd/nw/dialog_prefs.html index 59a59c3cc..4a19b6083 100644 --- a/pd/nw/dialog_prefs.html +++ b/pd/nw/dialog_prefs.html @@ -399,14 +399,14 @@ function cancel() { //pdgui.pdsend(pd_object_callback + " cancel"); } -function resize_window() { - var w = document.body.scrollWidth, - h = document.body.scrollHeight, - win = pdgui.get_dialogwin(pd_object_callback); - win.width = w; - win.height = h; -pdgui.gui_post("w is " + w + " and h is " + h); -} +//function resize_window() { +// var w = document.body.scrollWidth, +// h = document.body.scrollHeight, +// win = pdgui.get_dialogwin(pd_object_callback); +// win.width = w; +// win.height = h; +//pdgui.gui_post("w is " + w + " and h is " + h); +//} function change_api(elem) { var id = elem.getAttribute('id'), @@ -530,7 +530,8 @@ function audio_prefs_callback(attrs) { // have the side-effect of setting the dev to 'None') set_chans('in', get_attr('pd-inchans', attrs)); set_chans('out', get_attr('pd-outchans', attrs)); - resize_window(); + + pdgui.resize_window(pd_object_callback); } function set_devs(type, devs) { @@ -564,7 +565,8 @@ function midi_prefs_callback(attrs) { get_attr('current-api', attrs) ); } - resize_window(); + + pdgui.resize_window(pd_object_callback); } diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js index d419763b1..7ff651541 100644 --- a/pd/nw/pdgui.js +++ b/pd/nw/pdgui.js @@ -3524,7 +3524,7 @@ gui_post("did is " + did + " and dialogwin[did] is " + dialogwin[did]); function gui_font_dialog(cid, gfxstub, font_size) { var attrs = { canvas: cid, font_size: font_size }; - dialogwin[gfxstub] = nw_create_window(gfxstub, 'font', 265, 540, 20, 20, 0, + dialogwin[gfxstub] = nw_create_window(gfxstub, 'font', 265, 265, 20, 20, 0, 0, 1, 'white', 'Properties', '', 0, null, attrs); } @@ -3840,3 +3840,10 @@ exports.dialog_bindings = function(did) { } }; } + +exports.resize_window = function(did) { + var w = dialogwin[did].window.document.body.scrollWidth, + h = dialogwin[did].window.document.body.scrollHeight; + dialogwin[did].width = w; + dialogwin[did].height = h; +} -- GitLab