5 Replies Latest reply on Nov 6, 2011 12:16 PM by Peter Kahrel

    AutoLayout of tall items?

    John Hawkinson Level 5

      I want a window to have a fairly large listbox. If I just set this up naively, I find that the AutoLayoutManager gives my list all the available height, and leaves no room for objects created after it.

      For instance:



      var w = new Window("dialog");
      w.text0 = w.add("statictext", undefined, "hamburger");
      w.biglist = w.add("listbox", undefined, new Array(200).join("x").split(""));
      w.text = w.add("statictext", undefined, "cheeseburger");
      $.writeln("Window is "+w.size,"\n",
          "Text0 is " +w.text0.size,"\n",
          "Biglist is " +w.biglist.size,"\n",
          "Text is " +w.text.size,"\n"


      Gives these sizes:



      Window is 116,1870
      Text0 is 70,16
      Biglist is 33,1870
      Text is undefined


      That is, the biglist is assigned the full height of its parent window, which means even without Text, it doesn't fit since some of the space is taken by Text0. And there's no space for Text.


      How can I fix this?


      I can set the size of biglist to some fraction of the parent window, but that is awkward.

      Especially because this is an oversimplified example. In reality, biglist is inside a a panel that is inside a group, so I would need to set those sizes automatically.


      Isn't the AutoLayoutManager supposd to solve this for me?



        • 1. Re: AutoLayout of tall items?
          Harbs. Level 6

          Why are you calling w.layout.layout(true)?


          Try removing that line.



          • 2. Re: AutoLayout of tall items?
            John Hawkinson Level 5

            That's no help.


            Window.show() is defined to call the layout function to compute -- that was a vestige of an experiment with calculating the layout, adjusting the size based on the calculated preferredSize, and then re-calculating the layout.


            So removing layout() means putting the $.writeln() after the w.show(), and that just gives the same numbers and problems.

            • 3. Re: AutoLayout of tall items?
              Peter Kahrel Adobe Community Professional & MVP

              There are various problems with the autoloayout manager. A workaround for the problem you describe is the following:




              which automatically adjusts the list to the screen/window.



              1 person found this helpful
              • 4. Re: AutoLayout of tall items?
                John Hawkinson Level 5

                Ugh...thanks, Peter.

                I had tried something like that, but my experiments in that space failed (not sure why, it was late).


                My solution was to call .layout.layout(true) and then adjust down the size of the containers of biglist by a constant factor.


                As you note in SUFD, I worry about $.screens on multi-monitor machines (as most of ours are). Perhaps not such a big deal for height as width, but it turns out I have width problems too.


                I'm not sure if it is better to call .layout.layout(true) and use the size of the window to change the size constraints, and then call .layout.layout(true) a second time; or if it is better to use your method.


                There are various problems with the autoloayout manager

                I had hoped I was just misunderstanding. Do know if anything's been filed and do you have any bug numbers?

                • 5. Re: AutoLayout of tall items?
                  Peter Kahrel Adobe Community Professional & MVP

                  You're right, this is probably better:


                  w.biglist.maximumSize.height = w.biglist.size[1]-(some constant)


                  to get around the multi-screen problem. (Somehow my windows always end up on screen 0, probably because Indesign permanently lives there.)