From 888be938f1666c62abeb5b472b9c0e55cb2aa023 Mon Sep 17 00:00:00 2001 From: Jonathan Wilkes <jon.w.wilkes@gmail.com> Date: Tue, 29 Dec 2015 00:38:42 -0500 Subject: [PATCH] clean up the nw_create_window paramaters --- pd/nw/index.js | 16 +++++++++++----- pd/nw/pdgui.js | 36 ++++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/pd/nw/index.js b/pd/nw/index.js index 01349ef86..757f71fc9 100644 --- a/pd/nw/index.js +++ b/pd/nw/index.js @@ -287,12 +287,18 @@ function nw_close_window(window) { } // Way too many arguments here-- rethink this interface -function nw_create_window(cid, type, width, height, xpos, ypos, menu_flag, - resize, topmost, cnv_color, canvas_string, dir, dirty_flag, cargs, - attr_array) { +function nw_create_window(cid, type, width, height, xpos, ypos, attr_array) { // todo: make a separate way to format the title for OSX - var my_title = pdgui.format_window_title(canvas_string, dirty_flag, - cargs, dir); + var my_title; + if (type === "pd_canvas") { + my_title = pdgui.format_window_title( + attr_array.name, + attr_array.dirty, + attr_array.args, + attr_array.dir); + } else { + my_title = type; + } var my_file = type === "pd_canvas" ? "pd_canvas.html" : "dialog_" + type + ".html"; diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js index ac06fcd2c..0a30bfb76 100644 --- a/pd/nw/pdgui.js +++ b/pd/nw/pdgui.js @@ -929,8 +929,16 @@ function gui_canvas_new(cid, width, height, geometry, editable, name, dir, dirty // Not sure why resize and topmost are here-- but we'll pass them on for // the time being... patchwin[cid] = nw_create_window(cid, "pd_canvas", width, height, - xpos, ypos, menu_flag, resize[cid], topmost[cid], my_canvas_color, - name, dir, dirty_flag, cargs, null); + xpos, ypos, { + menu_flag: menu_flag, + resize: resize[cid], + topmost: topmost[cid], + color: my_canvas_color, + name: name, + dir: dir, + dirty: dirty_flag, + args: cargs + }); // initialize variable to reflect that this window has been opened loaded[cid] = 1; } @@ -3140,18 +3148,15 @@ function attr_array_to_object(attr_array) { } function gui_gatom_dialog(did, attr_array) { - dialogwin[did] = nw_create_window(did, "gatom", 265, 300, 20, 20, 0, - 0, 1, "white", "Properties", "", 0, null, - attr_array_to_object(attr_array) - ); + dialogwin[did] = nw_create_window(did, "gatom", 265, 300, 20, 20, + attr_array_to_object(attr_array)); } function gui_iemgui_dialog(did, attr_array) { //for (var i = 0; i < attr_array.length; i++) { // attr_array[i] = '"' + attr_array[i] + '"'; //} - dialogwin[did] = nw_create_window(did, "iemgui", 265, 450, 20, 20, 0, - 0, 1, "white", "Properties", "", 0, null, + dialogwin[did] = nw_create_window(did, "iemgui", 265, 450, 20, 20, attr_array_to_object(attr_array)); } @@ -3165,8 +3170,8 @@ function gui_create_array(did, count) { array_outline: "black", array_in_existing_graph: 0 }]; - dialogwin[did] = nw_create_window(did, "canvas", 265, 340, 20, 20, 0, - 0, 1, "white", "Properties", "", 0, null, attr_array); + dialogwin[did] = nw_create_window(did, "canvas", 265, 340, 20, 20, + attr_array); } function gui_canvas_dialog(did, attr_arrays) { @@ -3180,8 +3185,8 @@ function gui_canvas_dialog(did, attr_arrays) { } } } - dialogwin[did] = nw_create_window(did, "canvas", 250, 100, 20, 20, 0, - 0, 1, "white", "Properties", "", 0, null, attr_arrays); + dialogwin[did] = nw_create_window(did, "canvas", 250, 100, 20, 20, + attr_arrays); } function gui_remove_gfxstub(did) { @@ -3193,8 +3198,8 @@ function gui_remove_gfxstub(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, 265, 20, 20, 0, - 0, 1, "white", "Properties", "", 0, null, attrs); + dialogwin[gfxstub] = nw_create_window(gfxstub, "font", 265, 265, 20, 20, + attrs); } // Global settings @@ -3208,8 +3213,7 @@ function gui_pd_dsp(state) { function open_prefs() { if (!dialogwin["prefs"]) { dialogwin["prefs"] = nw_create_window("prefs", "prefs", - 265, 540, 20, 20, 0, - 0, 1, "white", "Properties", "", 0, null, null); + 265, 540, 20, 20, null); } } -- GitLab