DirectGUI and non-standard coordinate systems patch

Here is a patch that allows DirectGUI to work properly when the coordinate system is something other than Z-up.

1 Like

Mmm maybe I should have tested better.
The position argument is not taken properly. I will post again after further testing.

Seems it is the part that detects if the mouse is over the button or not, whereabouts in the code is that?

DirectGui is layered on top of PGui, which detects the mouse position by creating a MouseWatcherRegion for each clickable region, and passing these to the MouseWatcher (which actually does the detection).

If you’re failing to detect mouse clicks, I suspect it’s creating zero-sized MouseWatcherRegions. Note that you can visualize the MouseWatcherRegions with this call:

base.mouseWatcherNode.showRegions(render2d, 'gui-popup', 0)


Well it is detecting the clicks, just in the wrong location. In my case the vertical axis is not applied since it is hard-coded somewhere to use Z-axis.

That would be somewhere in DirectGui code, I think. At some point the DirectGui code makes a call to PGItem.setFrame() to set up the four coordinates of the 2-d rectangle. Probably it’s happening in DirectGuiBase.setFrameSize().


Ah, found it.
I’ve replaced the patch file above with an updated one. It seems to behave now for moved and/or rotated buttons and things.

I’ve fixed up the OnScreenText now also.
The last thing I need for now is the DirectEntry. I’ve got it mostly working. I can click in the box, I see the blinking cursor, I can type and the cursor moves appropriately, but I can’t see the actual text.
I suspected textNode was the problem, but it seems to have a coordinate system conversion already in place. Any ideas on that?
I think I’ve got everything in and pgEntry.cxx.

The pgEntry was using TextAssembler directly, which is why my poking around in TextNode had no effect.
I added a coordinate system conversion transform on the nodepath of the text in pgEntry and it works well now. I feel my work is a bit too sloppy for inclusion in the repository, though.
Actually I realize now a lot of the code I changed could probably have been left untouched by just applying transforms on nodepaths. Does that sound like the better solution?
I don’t mind redoing it the right way to bring it up to snuff to include.

I updated the file posted above to include the sum total of my changes incase anyone wants to use that.

Could you tell what this change brings in short?
Does this make placing GUI objects with random transforms possible? At least this is what I picked up.

No, he’s talking about supporting DirectGui when you have “coordinate-system y-up” in your Config.prc file. Currently, changing the default coordinate system from z-up to y-up breaks DirectGui.

Thanks for reminding me about this post, though–I plan to check it out shortly. Thanks for your efforts!


1 Like