I made a simple test
@Override
public void simpleInitApp() {
GuiGlobals.initialize(this);
BaseStyles.loadGlassStyle();
GuiGlobals.getInstance().getStyles().setDefaultStyle("glass");
guiViewPort.addProcessor(reshapeListener);
screen = new Container(new BorderLayout());
screen.setBackground(null);
screen.setLocalTranslation(0, cam.getHeight(), zOffset);
Container topBar = screen.addChild(new Container(new BorderLayout()), BorderLayout.Position.North);
topBar.setBackground(null);
Container topLeft = topBar.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y, FillMode.None, FillMode.None)), BorderLayout.Position.West);
topLeft.setBackground(null);
Container topCenter = topBar.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y, FillMode.None, FillMode.None)), BorderLayout.Position.Center);
topCenter.setInsetsComponent(new DynamicInsetsComponent(0.5f, 0.5f, 0.5f, 0.5f));
topCenter.setBackground(null);
Container topRight = topBar.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y, FillMode.None, FillMode.None)), BorderLayout.Position.East);
topRight.setBackground(null);
topLeft.addChild(new Button("Left"));
topLeft.addChild(new Button("Left 2"));
topLeft.addChild(new Button("Left 3"));
topLeft.addChild(new Button("Left 4"));
topCenter.addChild(new Button("Center"));
topRight.addChild(new Button("Right"));
guiNode.attachChild(screen);
resetScreenSize();
}
As the left side grows the center is moving toward the right, is there a way I can force the center panel to be always at the “center” of the screen?
Edit:
With a slight change in the layout, I could fix it.
I changed the top panel from a border layout to a spring grid layout with FillMode.ForcedEven
and also added a dynamic inset to it’s left and right borders.
Container topBar = screen.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y, FillMode.ForcedEven, FillMode.None)), BorderLayout.Position.North);
topBar.setBackground(null);
Container topLeft = topBar.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y, FillMode.Proportional, FillMode.None)));
topLeft.setInsetsComponent(new DynamicInsetsComponent(0.5f, 0f, 0.5f, 1f));
topLeft.setBackground(null);
Container topCenter = topBar.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y, FillMode.Proportional, FillMode.None)));
topCenter.setInsetsComponent(new DynamicInsetsComponent(05f, 0.5f, 0.5f, 0.5f));
topCenter.setBackground(null);
Container topRight = topBar.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y, FillMode.Proportional, FillMode.None)));
topRight.setInsetsComponent(new DynamicInsetsComponent(0.5f, 1f, 0.5f, 0f));
topRight.setBackground(null);