Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Augustifolia opened this issue Jan 14, 2024 · 3 comments
Labels

Comments

@Augustifolia
Copy link

Augustifolia commented Jan 14, 2024

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++):
@ArsThaumaturgis
Copy link
Contributor

ArsThaumaturgis commented Jan 22, 2024

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.

@rdb rdb added the bug label Jan 23, 2024
@rdb rdb self-assigned this Jan 23, 2024
@rdb rdb added this to the 1.11.0 milestone Jan 23, 2024
@rdb rdb removed their assignment Jan 23, 2024
@rdb rdb removed this from the 1.11.0 milestone Jan 23, 2024
@rdb
Copy link
Member

rdb commented Jan 23, 2024

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

@Augustifolia
Copy link
Author

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants