Hiding panel won't hide elements added to it if panel not added to screen

Something like this:

[java] // Making the screen and its components.
String pathToImg = “Textures/Gui/inventoryTest.png”;
Vector2f size = new Vector2f(48f, 48f);
inventory = new Panel(screen, manager.getSettings().getInventoryPosition(), ScreensDefaults.INVENTORY_SIZE, Vector4f.ZERO, pathToImg);
float x, xStart = 6;
float y, yStart = 145;
for (int i = 0; i < 4; i++) {
y = i * 53 + yStart;
for (int j = 0; j < 9; j++) {
x = j * 53 + xStart;
Element slot = new Element(screen, “slot” + i, new Vector2f(x, y), size, Vector4f.ZERO, null);
slot.setBackgroundColor(ColorRGBA.DarkGray.mult(new ColorRGBA(1, 1, 1, .5f)));
inventory.addChild(slot);
}
}
inventory.hide();
[/java]

All the slots will still be visible even though the main panel won’t be.

The only way I can have those hidden is by calling inventory.hide() after the panel (inventory) has been attached to the screen. Any call before that’s done won’t work. :frowning:

I know it’s just a minor thing, but… well, I don’t think it should behave that way. :slight_smile:

@madjack said: Something like this:

[java] // Making the screen and its components.
String pathToImg = “Textures/Gui/inventoryTest.png”;
Vector2f size = new Vector2f(48f, 48f);
inventory = new Panel(screen, manager.getSettings().getInventoryPosition(), ScreensDefaults.INVENTORY_SIZE, Vector4f.ZERO, pathToImg);
float x, xStart = 6;
float y, yStart = 145;
for (int i = 0; i < 4; i++) {
y = i * 53 + yStart;
for (int j = 0; j < 9; j++) {
x = j * 53 + xStart;
Element slot = new Element(screen, “slot” + i, new Vector2f(x, y), size, Vector4f.ZERO, null);
slot.setBackgroundColor(ColorRGBA.DarkGray.mult(new ColorRGBA(1, 1, 1, .5f)));
inventory.addChild(slot);
}
}
inventory.hide();
[/java]

All the slots will still be visible even though the main panel won’t be.

The only way I can have those hidden is by calling inventory.hide() after the panel (inventory) has been attached to the screen. Any call before that’s done won’t work. :frowning:

I know it’s just a minor thing, but… well, I don’t think it should behave that way. :slight_smile:

It certainly shouldn’t.

The way I handle this internally, is to add it to the screen then call hide. Since this all happens on the same frame, there is no visual of this happening. It basically sets a parent/child relationship for the Element class and then uses JME’s .removeFromParent to only remove the actual Node from the scene without removing internal hierarchy.

There is another glitch that is note worthy, that I haven’t come up with an internal solution to. Remembering the hidden state of a child element doesn’t work as it was intended to. There is an internal mechanism for tracking this, however, there appears to be an issue with it (what that issue is… I have no clue yet). So, do keep it in mind when dealing with multiple layered hide/shows.

I have a working example here of the problem and I’m trying to find a fix. Give me a bit and I’ll post what I am doing to make the problem happen and what you can do to avoid the issue for the time being–in case this one pops up for you as well.

Ok… here is the how I am creating the problem:

  • I have three windows that I made collapsable, at most times these windows are attached to the screen, but if you destroy the object they display properties for, the windows are hidden.
  • When the windows are collapsed, I hide the child element that contains all the controls for the window.
  • If the windows are removed while collapsed, they are not shown while I add the windows back into the scene at auto expand the selected window.

The way I fixed the issue, was to add the windows back to the screen, auto-expand the appropriate window, then call show on the child.

Heh… while talking about this, I think I just saw the problem that creates both the issue you reported and the related issue I was describing.

In childShow(), isVisible = wasVisible is being set, however, it doesn’t look like it is ever calling setIsVisible with the updated value.

I’ll test this out and see if it fixes then problem and commit the change if it works.

Just to make sure we’re talking about the same issue here, it’s the slots that are not hidden. The panel itself disappears, but the slots stay put.

@madjack said: Just to make sure we're talking about the same issue here, it's the slots that are not hidden. The panel itself disappears, but the slots stay put.

Yes… I think these issues are related to the isVisible, wasVisible state and it not being properly set when adding an element to the scene or reshowing it after hiding it.