package it.cavallium.warppi.gui.expression.blocks;

import it.cavallium.warppi.gui.GraphicalElement;

public interface BlockOrContainer extends GraphicalElement {
	BlockOrContainer getParent();
	BlockOrContainer getAt(int index);

	default void recomputeDimensionsToRoot() {
		var parent = this;
		while (parent != null) {
			parent.recomputeDimensions();
			parent = parent.getParent();
		}
	}

	default BlockContainer getRootContainer() {
		var parent = this;
		while (parent != null) {
			parent = parent.getParent();
		}
		return (BlockContainer) parent;
	}

	int getIndex();
}
