DirectScrollList reparenting issue

Well, I needed an onscreen Panda3D console to make debugging easier, as I wouldn’t have to switch between the terminal and my running Panda3D instance.

So, I decided to roll my own. The closest thing I could find was DirectScrollList.

One of the requirements for the console was that it constantly kept its horizontal size to the width of the screen (i.e, it filled the screen horizontally), so I just reparented the DirectScrollList to render2d so I wouldn’t have to mess with constantly retrieving the aspect ratio.
However, the scroll buttons would no longer work!

Any solutions?

Thanks in advance!

Hi, DirectGui 2d elements that interact with the mouse must be under the aspect2d node, because aspect2d is actually underneath the render2d node. Aspect2d provides the mouse support for buttons :wink:

A fix so that instead of querying the aspect ratio would be to set a fixed aspect ratio for the aspect2d node, this can be done by placing "aspect-ratio " in your Config.prc file. For instance you could replace the area with with 1.0 and aspect2d will (instead of scaling with the aspect ratio) provide a fixed aspect ratio identically to render2d, except buttons will work.

However, this might make your other gui elements looks funky and layout improperly (because it disables the whole point of aspect2d).

Best of luck.

Hmmm, so could I reparent just the scroll buttons to aspect2d?

I think for a DirectScrolledList the items must be parented to it (I could be wrong, but I think that’s correct), what you want to do is parent the DirectScrolledList to aspect2d. After that either use a task and check periodically (or accept the ‘window-event’ panda event) and check the aspect ratio through “base.getAspectRatio()” or optionally you can calculate it yourself using and or like I said apply the fixed aspect-ratio variable to your Config.prc file, which will set a fixed aspect ratio.

Question is, which way will you take? the cheap way out, using the fixed aspect-ratio which will make your gui stretch at larger sizes or the harder nicer approach using the window’s aspect ratio to scale the gui?

So basically, things like DirectScrolledList are meant to be parented to aspect2d, and so that’s probably how you should use them :smiley:
That is, only clickable gui items need be parented to the aspect2d node, other gui items such as text or ‘display only’ gui items can be anywhere, for instance text in the render (3d) node