Lemur style and attribute question (Container layout)

I have experimented with styling and attributes in Lemur.

I used a Springgridlayout to set 2 containers to a specific position.
That was working well.

Then I thought I would like to set that specific layout via style and attribute.

I have used the following code:

SpringGridLayout layoutasattribut = new SpringGridLayout(Axis.X,Axis.Y,FillMode.Even,FillMode.Even);

Container L1 = new Container();
L1.addChild(new Label("L1"));
  
Container L2 = new Container();
L2.addChild(new Label("L2"));
        
layoutasattribut.addChild(1,1,L1);
layoutasattribut.addChild(2,2,L2);


Attributes attr= styles.getSelector (new ElementId(Container.ELEMENT_ID),"Testlayout");
attr.set("layout",layoutasattribut);

Later in code I call the saved layout via


Container C1 = new Container(new ElementId(Container.ELEMENT_ID),"Testlayout");

but it is not showing the expected outcome. If I configure a container directly in
code like this

Container L3 = new Container(layoutasattribut);
GuiNode.attachChild(L3);
...


I can see the result shown above. It seems that the child containers, that are stored to the SpringGridLayout get lost during the application of the style.

In
com\simsilica\lemur\style\Styles.class, line 285
“value” contains the two children set via attribute

285    if (value != null) {
286                if (value instanceof GuiComponent) {
287                    value = ((GuiComponent)value).clone();

but the .clone() function in line 287 that leads to
\com\simsilica\lemur\component\SpringGridLayout.class, line 68
is loosing the children.

67  public SpringGridLayout clone() {
68       SpringGridLayout result = new SpringGridLayout(this.mainAxis, this.minorAxis, this.mainFill, this.minorFill);
69        return result;
   }

If I understood the code in SpringGridLayout.class this is intended.

My question(s) are:

How is it possible to store a layout with children as an style?
Is it usefull to do this or may it be better to do the setting in code when the
Gui is actually painted?

You can’t, really. This is not a “Style”.

I don’t know why you want to do it, ie: the real reason… so I can’t comment.

I have no real reason. I thought this would be a nice way to prepare a layout that I can reuse later.
I have no real case yet, so for me it makes no difference if I make a function that I call later or a style. I am still testing and checking lemur and its possibillities and tried a bit with styles.
But if you say it is not a style that is fine for me and yep it is even logical.

Cool. Well, if you think of anything else, just ask. I didn’t mean to sound dismissive.

Usually when one wants some specific layout to be repeatable then it starts to sound like that’s really a new GUI element that manages a set of children. (Like Slider does, like ListBox does, etc…)

If you have a specific use-case in mind at some point then we can get more specific about that.