I was having an issue with a panel being transparent when I didn’t want it to be. After trying lots of different things I realised that changing the z distance changed the transparency.
I can’t see anything in the lemur doc about this - there’s a reference to using z-order for layering but I’d assumed that would just be what was on top. I can’t work out why it would impact how transparent a panel is.
I’m using the glass style and haven’t changed anything from the default. I have tried setting the alpha for the panel, and for the buttons in the panel, but it doesn’t seem to make any difference - I’m assuming the style gets applied after I’ve created the component so my values are override.
Apologies if I’ve missed something obvious in the doc.
Here is the class that creates the panel:
public class OptionPanel extends Container {
private final float width;
public OptionPanel(String title, float width, float height) {
super(new SpringGridLayout(Axis.Y, Axis.X, FillMode.Last, FillMode.Even));
this.width = width;
setPreferredSize(new Vector3f(width, height, 0f));
setLocalTranslation(0f, 0f, 1f);
Label label = new Label(title);
label.setFontSize(20.0f);
addChild(label);
addBlank(10f);
}
@SuppressWarnings("unchecked")
public void addButton(String name, Runnable action) {
Button button = new Button(name);
button.addClickCommands(src -> action.run());
button.setAlpha(1f);
addChild(button);
}
public void addBlank(float height) {
Panel blank = new Panel();
blank.setPreferredSize(new Vector3f(width, height, 0f));
blank.setAlpha(0f);
addChild(blank);
}
}
I think OptionPanel is in proto right? I’m just using the main release at this stage. In any case it’s really just a name clash: this isn’t supposed to be a popup in the JOptionPane style. It’s closer to a menu with a list of buttons on it.
I took out the setPreferredStyle to see if it made any difference to transparency and it didn’t seem to change the visual behaviour at all.
I’m sorry I should have said ‘didn’t change the visual behaviour with respect to transparency’. It definitely changed the size: the panel size became the default determined by the layout. But the panel still looks less transparent the greater the z.
The methods constructing the option panel set the x and y position and then attach it to the gui. Actually I create a node that’s attached to app.getGuiNode() and everything is attached to that. That’s just to make it easy to hide the whole gui when required. I’ll try to change it to just attach everything to the main gui node to see if that changes the behaviour.
I’ll try coming up with a basic app without anything else in the scene to see if I get the same behaviour.
You can also look at the demo app and see if messing with its z values has any effect. I’ve never seen this behavior myself.
If you post back and I don’t respond right away it’s because I’m sleeping… we are entering the part of the week where I must sleep for more than 2 hours in a row.