panda3d icon indicating copy to clipboard operation
panda3d copied to clipboard

Setting frameColor for DirectGui objects changes its' size reported by getBounds()

Open Augustifolia opened this issue 1 year ago • 3 comments

Description

When changing the frame color of a DirectGui object, its' reported size is changed. But it still appears to be the same size on screen. This does not appear to happen with DirectFrame and DirectLabel, but most other DirectGui classes seems to be affected. Additionally it only happens when setting the frame color after object creation.

Edit: Apparently this also happens with frameTexture. Using something like this in the example below. button["frameTexture"] = "models/maps/circle.png"

Steps to Reproduce

from direct.showbase.ShowBase import ShowBase
from direct.gui.DirectGui import DirectButton

ShowBase()
button = DirectButton(text="gui")
print(button.getBounds())
button["frameColor"] = (1, 1, 1, 1)
print(button.getBounds())

base.run()

Environment

  • Operating system: Linux Mint
  • System architecture: x86_64
  • Panda3D version: 1.10.14
  • Installation method: pip
  • Python version (if using Python): 3.12.1
  • Compiler (if using C++):

Augustifolia avatar Jan 14 '24 15:01 Augustifolia

Based on some quick testing, it looks to me like the bounds have not yet been (fully?) calculated as of the first call to "getBounds", but that setting a property (or certain properties) prompts the relevant object to perform the calculation.

This can be seen, I think, if one alters the test-program above such that the print-outs happen later. In my case, I had them run in response to a key-press, like so:

from direct.showbase.ShowBase import ShowBase
from direct.gui.DirectGui import DirectButton

ShowBase()
button = DirectButton(text="gui")

def mew():
    print(button.getBounds())
    button["frameColor"] = (1, 1, 1, 1)
    print(button.getBounds())

base.accept("space", mew)

base.run()

On my end, running this version results in the same bounds being printed out in response to both calls.

ArsThaumaturgis avatar Jan 22 '24 20:01 ArsThaumaturgis

Could it be that this was already fixed? I can't reproduce this with latest master.

rdb avatar Jan 23 '24 14:01 rdb

It appears to be mostly fixed in latest master. However the issue still exists with the DirectDialogs.

from direct.showbase.ShowBase import ShowBase
from direct.gui.DirectGui import OkDialog

ShowBase()
button = OkDialog(text="gui")
print(button.getBounds())
button["frameColor"] = (1, 1, 1, 1)
print(button.getBounds())

base.run()

Augustifolia avatar Jan 23 '24 16:01 Augustifolia