<div dir="auto">Why not simply subtract the menu at height from the document height?<br><br><div data-smartmail="gmail_signature">Best,<br><br>Ico<br><br>-- <br>Ivica Ico Bukvic, D.M.A.<br>Director, Creativity + Innovation<br>Institute for Creativity, Arts, and Technology<br><br>Virginia Tech<br>Creative Technologies in Music<br>School of Performing Arts – 0141<br>Blacksburg, VA 24061<br>(540) 231-6139<br><a href="mailto:ico@vt.edu">ico@vt.edu</a><br><br><a href="http://www.icat.vt.edu">www.icat.vt.edu</a><br><a href="http://www.performingarts.vt.edu">www.performingarts.vt.edu</a><br><a href="http://l2ork.icat.vt.edu">l2ork.icat.vt.edu</a><br><a href="http://ico.bukvic.net">ico.bukvic.net</a></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jun 14, 2020, 14:50 Jonathan Wilkes <<a href="mailto:jon.w.wilkes@gmail.com">jon.w.wilkes@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It appears there's a race condition with the nw.js Menu menubar<br>
rendering and nw.js actually<br>
updating the DOM.<br>
<br>
This means we have to rely on a timeout to get accurate window height<br>
report, and for<br>
some heavy patches this won't be enough.<br>
<br>
That's why you get the extra height at the bottom of the window for<br>
some help patches.<br>
<br>
I just filed a bug on nw.js google group. Hopefully Roger can fix it<br>
our at least give us a<br>
callback when it's done rendering.<br>
<br>
-Jonathan<br>
<br>
On Sun, Jun 14, 2020 at 1:09 AM Jonathan Wilkes <<a href="mailto:jon.w.wilkes@gmail.com" target="_blank" rel="noreferrer">jon.w.wilkes@gmail.com</a>> wrote:<br>
><br>
> Excalibur successfully retrieved.<br>
><br>
> And the secret CSS incantation is...<br>
><br>
> float: left;<br>
><br>
> Initial implementation below. I've got the scrollbars hard-coded atm,<br>
> but they can easily be measured at startup.<br>
><br>
> Also-- I added some overflow offsets so that if a scrollbar is needed,<br>
> then there is some padding below the object.<br>
> That always drives me crazy when I scroll down and the bottom of the<br>
> object is flush with the scrollbar or the<br>
> bottom of the window.<br>
><br>
> diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js<br>
> index a24a6f71..7ff9fdab 100644<br>
> --- a/pd/nw/pdgui.js<br>
> +++ b/pd/nw/pdgui.js<br>
> @@ -5774,8 +5774,8 @@ function canvas_params(nw_win)<br>
>      // the scrollbars from appearing. Here, we just subtract 4 from both<br>
>      // of them. This could lead to some problems with event handlers but I<br>
>      // haven't had a problem with it yet.<br>
> -    min_width = nw_win.window.innerWidth - 4;<br>
> -    min_height = nw_win.window.innerHeight - 4;<br>
> +    min_width = nw_win.window.innerWidth;<br>
> +    min_height = nw_win.window.innerHeight;<br>
>      // Since we don't do any transformations on the patchsvg,<br>
>      // let's try just using ints for the height/width/viewBox<br>
>      // to keep things simple.<br>
> @@ -5799,24 +5799,82 @@ function do_getscroll(cid) {<br>
>      // errors wrt the rendering context disappearing.<br>
>      gui(cid).get_nw_window(function(nw_win) {<br>
>          var svg_elem = nw_win.window.document.getElementById("patchsvg");<br>
> +        var overflow_x,<br>
> +            overflow_y,<br>
> +            scrollbar_x_would_overlap_content,<br>
> +            scrollbar_y_would_overlap_content,<br>
> +            x_offset = 0,<br>
> +            y_offset = 0;<br>
>          var { x: x, y: y, w: width, h: height,<br>
>              mw: min_width, mh: min_height } = canvas_params(nw_win);<br>
> +<br>
> +        // Let's get to it. First we want to know if our SVG has any child<br>
> +        // elements overflowing our viewport<br>
> +<br>
> +        overflow_x = width > min_width;<br>
> +        overflow_y = height > min_height;<br>
> +<br>
> +        // Now let's see if drawing a scrollbar would hide objects at the<br>
> +        // extremities of the viewport<br>
> +<br>
> +        scrollbar_x_would_overlap_content = height > min_height - 15;<br>
> +        scrollbar_y_would_overlap_content = width > min_width - 15;<br>
> +<br>
> +        if (overflow_x) {<br>
> +            // We have a horizontal scrollbar.<br>
> +            if (scrollbar_x_would_overlap_content) {<br>
> +                // If there are objects underneath the horizontal scrollbar,<br>
> +                // we want to make sure that the height of our SVG covers<br>
> +                // the entire viewport. That way the browser will give us<br>
> +                // a vertical scrollbar in order to view those objects<br>
> +                y_offset = 0;<br>
> +            } else {<br>
> +                // We don't need a vertical scrollbar after all. So make the<br>
> +                // canvas 15 pixels shorter so the vertical scrollbar doesn't<br>
> +                // show up<br>
> +                y_offset = -15;<br>
> +            }<br>
> +        }<br>
> +<br>
> +        if (overflow_y) {<br>
> +            // vert scrollbar<br>
> +            if (scrollbar_y_would_overlap_content) {<br>
> +                // same as above<br>
> +                x_offset = 0;<br>
> +            } else {<br>
> +                x_offset = -15;<br>
> +            }<br>
> +        }<br>
> +<br>
> +        // Finally, if we overflow the viewport, let's add some padding so<br>
> +        // that objects at the edge aren't flush against the scrollbar. At<br>
> +        // least I find that a real pain at the bottom of the window when<br>
> +        // trying to add more objects<br>
> +<br>
> +        if (overflow_x) {<br>
> +            x_offset = 5;<br>
> +        }<br>
> +<br>
> +        if (overflow_y) {<br>
> +            y_offset = 5;<br>
> +        }<br>
> +<br>
>          if (width < min_width) {<br>
>              width = min_width;<br>
>          }<br>
> -        // If the svg extends beyond the viewport, it might be nice to pad<br>
> -        // both the height/width and the x/y coords so that there is extra<br>
> -        // room for making connections and manipulating the objects.  As it<br>
> -        // stands objects will be flush with the scrollbars and window<br>
> -        // edges.<br>
> +        width += x_offset;<br>
> +<br>
>          if (height < min_height) {<br>
> -            height = min_height;<br>
> +            height = min_height<br>
>          }<br>
> +        height += y_offset;<br>
> +<br>
>          configure_item(svg_elem, {<br>
>              viewBox: [x, y, width, height].join(" "),<br>
>              width: width,<br>
>              height: height<br>
>          });<br>
> +<br>
>      });<br>
>  }<br>
_______________________________________________<br>
L2Ork-dev mailing list<br>
<a href="mailto:L2Ork-dev@disis.music.vt.edu" target="_blank" rel="noreferrer">L2Ork-dev@disis.music.vt.edu</a><br>
<a href="https://disis.music.vt.edu/listinfo/l2ork-dev" rel="noreferrer noreferrer" target="_blank">https://disis.music.vt.edu/listinfo/l2ork-dev</a></blockquote></div>