Correctly syncing lemur components size

Currently I find myself (when trying to synchronize a panel size with any other stuff) using a lot the next piece of code when using lemur:

getControl(GuiControl.class).addComponent(new AbstractGuiComponent() {
    @Override
    public void calculatePreferredSize(Vector3f size) {

    }

    @Override
    public void reshape(Vector3f pos, Vector3f size) {
         // Do some size syncing
    }
});

but while I’m almost sure this is safe I don’t really know it.

The alternative to it in a non-lemur way would be:

addControl(new AbstractControl() {
    Vector3f lastSize;

    @Override
    protected void controlUpdate(float tpf) {
        Vector3f size = SuperClass.this.getSize();
        if(!size.equals(lastSize)) {
            lastSize.set(size);
            // Do some size syncing
        }
    }
});

However this one adds more overhead on every loop and worst than that, I like it less!! xD. So my question here is… it is safe to use the first piece of code?, I’m not being aware of something important?

http://jmonkeyengine-contributions.github.io/Lemur/javadoc/Lemur/com/simsilica/lemur/core/GuiControl.html#addListener(com.simsilica.lemur.core.GuiControlListener)

http://jmonkeyengine-contributions.github.io/Lemur/javadoc/Lemur/com/simsilica/lemur/core/GuiControlListener.html

1 Like

-O- I missed it (obviously), thanks.