diff --git a/pd/nw/css/default.css b/pd/nw/css/default.css index 5abd5f15e8170544e966dc688e68a73c4c922c38..b58290b90e7d76f6f8dc1d771f21e7c3182b807b 100644 --- a/pd/nw/css/default.css +++ b/pd/nw/css/default.css @@ -189,11 +189,11 @@ mark { mark.console_find_current.console_find_highlighted, mark.console_find_current { - background: yellow; + background: #e87216; } mark.console_find_highlighted { - background: red; + background: yellow; } #console_find { @@ -521,6 +521,18 @@ text { fill: gray !important; } +#console_find { + width: 100%; + height: 1em; + padding-top: 2px; + padding-left: 2px; + padding-bottom: 8px; + background: silver; + position: fixed; + bottom: 0; + left: 0; +} + #canvas_find { width: 100%; height: 1em; diff --git a/pd/nw/index.html b/pd/nw/index.html index 32da532bc10216281b13124ef8e17e571715f6b8..d96e25ef000800b9d94428955fe8ec156131db85 100644 --- a/pd/nw/index.html +++ b/pd/nw/index.html @@ -30,20 +30,19 @@ </div> </div> <div id="console_find" style="display:none;"> - <div> - <label><input type="text" - id="console_find_text" - name="console_find_text" - defaultValue="Search in Console" - style="width:10em;"/> - </label> - <label>Highlight All - <input type="checkbox" - id="console_find_highlight" - name="console_find_highlight" - onchange="console_find_highlight_all(this);"/> - </label> - </div> + <label><input type="text" + id="console_find_text" + name="console_find_text" + defaultValue="Search in Console" + style="width:10em"/> + </label> + <label style="margin-left: 7px; margin-right: -3px;">Highlight All + <input type="checkbox" + id="console_find_highlight" + name="console_find_highlight" + onchange="console_find_highlight_all(this);" + style="position: relative; top: 2px; margin-right: 5px;"/> + </label> </div> <script src="./console_search.js"></script> <script type="text/javascript" src="index.js"></script> diff --git a/pd/nw/index.js b/pd/nw/index.js index 8c777871fede74fd90718c7b19d7aaba3885f72c..4a5476697bfac417a266fa686e8ea5b5bb07c39b 100644 --- a/pd/nw/index.js +++ b/pd/nw/index.js @@ -384,6 +384,11 @@ function nw_close_window(window) { // 0.46+ seems to be required for "null" to work. TODO: Bisect to get the // actual minimum required version for this. var null_pos = pdgui.check_nwjs_version("0.46") ? "null" : "center"; +// ico@vt.edu 2020-08-12: this is no longer needed as it turns out that +// there are OS differences rather than nw.js differences. That said, +// we are still keeping this here for once we migrate to 0.46+ as it may +// still prove useful... +var menu_offset = pdgui.check_nwjs_version("0.46") ? 25 : 25; function nw_create_window(cid, type, width, height, xpos, ypos, attr_array) { // todo: make a separate way to format the title for OSX @@ -409,6 +414,10 @@ function nw_create_window(cid, type, width, height, xpos, ypos, attr_array) { pos = "center"; } else { pos = null_pos; + //pdgui.post("check_os=" + pdgui.check_os("win32")); + if (pdgui.check_os("linux") == 1) { + ypos = ypos - menu_offset - 3; + } } gui.Window.open(my_file, { title: my_title, @@ -421,7 +430,7 @@ function nw_create_window(cid, type, width, height, xpos, ypos, attr_array) { // altogether to simplify things. But we'd have to add some kind of // widget for the "Put" menu. // ico@vt.edu: on 0.46.2 this is now 25, go figure... - height: height + 25, + height: height + menu_offset, x: xpos, y: ypos }, function (new_win) { @@ -597,7 +606,7 @@ function nw_create_pd_window_menus(gui, w) { if (state === "none") { text_container.style.setProperty("bottom", "1.6em"); find_bar.style.setProperty("display", "inline"); - find_bar.style.setProperty("height", "1.2em"); + //find_bar.style.setProperty("height", "1.2em"); // Don't do the following in logical time so that the // console_find keypress event won't receive this shortcut key window.setTimeout(function() { diff --git a/pd/nw/locales/en/translation.json b/pd/nw/locales/en/translation.json index e7a8510191e040baa874336b085caaf65711450b..2cabcff0acfd3082066a2193330adfde20a0a74b 100644 --- a/pd/nw/locales/en/translation.json +++ b/pd/nw/locales/en/translation.json @@ -270,7 +270,8 @@ }, "pd_window": { "find": { - "placeholder": "Search in Console" + "placeholder": "Search in Console", + "highlight": "Highlight All" } }, "canvas": { diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js index fff02522f3c61f5283b8f97c37deea65743b11ac..583e4f7042a3f8866954314a896fb26dd4509557 100644 --- a/pd/nw/pdgui.js +++ b/pd/nw/pdgui.js @@ -815,9 +815,21 @@ function check_nwjs_version(version) { exports.check_nwjs_version = check_nwjs_version; +// ico@vt.edu 2020-08-12: check which OS we have since Windows has a different +// windows positioning logic on nw.js 0.14.7 than Linux/OSX. Go figure... +function check_os(name) { + + var os = require('os'); + //post("os=" + os.platform()); + return os.platform() === name ? 1 : 0; +} + +exports.check_os = check_os; + // ico@vt.edu 2020-08-11: this appears to have to be 25 at all times -// perhaps this is different on Linux and OSX? -var menu_offset = check_nwjs_version("0.46") ? 25 : 25; +// we will leave this here for later if we encounter issues with inconsistencies +// across different nw.js versions... +var nwjs_menu_offset = check_nwjs_version("0.46") ? 25 : 25; // quick hack so that we can paste pd code from clipboard and // have it affect an empty canvas' geometry @@ -825,8 +837,8 @@ var menu_offset = check_nwjs_version("0.46") ? 25 : 25; function gui_canvas_change_geometry(cid, w, h, x, y) { gui(cid).get_nw_window(function(nw_win) { nw_win.width = w; - // menu_offset is a kludge to account for menubar - nw_win.height = h + menu_offset; + // nwjs_menu_offset is a kludge to account for menubar + nw_win.height = h + nwjs_menu_offset; nw_win.x = x; nw_win.y = y; }); @@ -843,18 +855,18 @@ function canvas_check_geometry(cid) { // in nw_create_window of index.js // ico@vt.edu in 0.46.2 this is now 25 pixels, so I guess // it is now officially kludge^2 - win_h = patchwin[cid].height - menu_offset, + win_h = patchwin[cid].height - nwjs_menu_offset, win_x = patchwin[cid].x, win_y = patchwin[cid].y, cnv_width = patchwin[cid].window.innerWidth, - cnv_height = patchwin[cid].window.innerHeight - menu_offset; + cnv_height = patchwin[cid].window.innerHeight - nwjs_menu_offset; // We're reusing win_x and win_y below, as it // shouldn't make a difference to the bounds // algorithm in Pd (ico@vt.edu: this is not true anymore for nw 0.46+) //post("relocate " + pd_geo_string(cnv_width, cnv_height, win_x, win_y) + " " + // pd_geo_string(cnv_width, cnv_height, win_x, win_y)); // IMPORTANT! ico@vt.edu: for nw 0.46+ we will need to replace first pd_geo_string's - // first two args (win_w and win_h with cnv_width and cnv_height + menu_offset + // first two args (win_w and win_h with cnv_width and cnv_height + nwjs_menu_offset // to ensure the window reopens exactly how it was saved) pdsend(cid, "relocate", pd_geo_string(win_w, win_h, win_x, win_y), @@ -2412,6 +2424,8 @@ function gui_canvas_line(cid,tag,type,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10) { frag.appendChild(path); return frag; }); + // ico@vt.edu 2020-08-12: update scroll when cord is drawn + gui_canvas_get_scroll(cid); } function gui_canvas_select_line(cid, tag) { @@ -2431,6 +2445,8 @@ function gui_canvas_delete_line(cid, tag) { gui(cid).get_elem(tag, function(e) { e.parentNode.removeChild(e); }); + // ico@vt.edu 2020-08-12: update scroll when cord is deleted + gui_canvas_get_scroll(cid); } function gui_canvas_update_line(cid, tag, x1, y1, x2, y2, yoff) { @@ -6022,7 +6038,9 @@ function canvas_params(nw_win) // To implement the Pd-l2ork behavior, the top-left of the canvas should // always be the topmost, leftmost object. width = bbox.x > 0 ? bbox.x + bbox.width : bbox.width; - height = bbox.y > 0 ? bbox.y + bbox.height : bbox.height; + // ico@vt.edu 2020-08-12: we add 1 due to an unknown nw.js discrapancy, + // perhaps because of rounding taking place further below? + height = bbox.y > 0 ? bbox.y + bbox.height + 1 : bbox.height + 1; x = bbox.x > 0 ? 0 : bbox.x, y = bbox.y > 0 ? 0 : bbox.y;