Remove global settings and instead pass a YGConfig struct to calculate layout #418
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
We need a way to configure tree calculation. Two examples are:
Currently these are global settings. This works if your application only has one instance of yoga but in some cases you may be running different frameworks which both use yoga (maybe without knowing it) and they may want to configure such settings differently. This is not currently possible.
I suggest adding a variant of
YGNodeCalculateLayout
calledYGNodeCalculateLayoutWithConfig
which takes aYGConfig
struct as a last parameter.I'd like to give this a go.
I'm not sure about the best way to structure the
YGConfig
. As we can quickly produce some binary incompatibilty here, as soon as we add a new experiment.Some pseudocode:
would change the struct size any time we change the experiments array. So for improved readability we could change to:
we still need to zero out the struct here. Thus I'm think of moving the creation to fully internall:
We need a lot more calls to set this up in C, but could be hidden by other languages. Best benefit, we can change without breaking the ABI, and it's always properly setup.
So the question is do we expose the struct to the caller or do we hide it internally?
What do you think @emilsjolander ?
You have definetly thought this through more than me! We could hide the
YGConfig
struct the same way we currently hideYGNode
. I'm not too worries about the C API being verbose as the C API tends to only be used from within other higher level frameworks and not in user space code.Ok, than I'll hide it like
YGNode
and keep the experiment array, so we can simple reuse (with a little change) the already existingYGSetExperimentalFeatureEnabled
.