voytech / tabulate

Kotlin library for exporting collections of object into tabular formats.
Apache License 2.0
2 stars 0 forks source link

Rewrite Layouts+RenderIterations #174

Closed voytech closed 2 months ago

voytech commented 8 months ago

[THIS IS ONLY PROPOSITION FOR SOLUTION]

  1. Merge Layout with LayoutSpace. They are always coupled togheter.
  2. Make Layout+LayoutSpace and RenderIterationAttributes components of single RenderIteration.

RenderIteration:

When measuring or exporting a model, new RenderIteration is created only if there are no pending planned iterations for that model.

When measuring the model and no iteration was planned on previous iteration, then new iteration is created ad-hoc without any continuation attributes.

When rendering the model which was already measured there should be always iteration to pop from stack - an iteration used to measure model. Such iteration contains persisted layout computations as well as layout space after first pass. Layout needs to restart layout space at current rendering position and then reset its own mutable state if needed (that depends on layout implementation.)

When parent layout space has insufficient room and x or y axis is crossed by the rendering operation, then depending on overflow strategy, engine may push next iteration for future consumption or e.g: skip rendering process in place.

Pushing new iteration (creating new instance) will set current phase status to pending.

Iteration can add new attributes during exporting multiple times.

pending Iteration can be discarded e.g: if overflow rule = skip or clip and skip. Iteration may be also discarded from parent model, when it has no room for rendering and has overflow rule set to skip or clip and skip.

Each time iteration is created it is in state planned, it has no layout (because layout will be created when state=running) When calling measure/export iteration is activated (state = running), layout + layout space are initialised using strategy defined on parentIteration layout instance.

Iteration may be re-attempted (when first we measure model, it creates RenderIteration and activates it, then at some point in tame parent model may trigger export on the model, where in context we already consumed iteration once - for layout , layout-space measurements)