65 lines
1.9 KiB
Java
65 lines
1.9 KiB
Java
package speiger.src.coreengine.rendering.newGui.components.base;
|
|
|
|
import speiger.src.coreengine.rendering.gui.helper.box.IGuiBox;
|
|
|
|
public interface ILayoutComponent {
|
|
public void calculateBounds(ILayoutScanner output);
|
|
public IGuiBox getBox();
|
|
|
|
public default float getX() {
|
|
return getBox().getMinX();
|
|
}
|
|
|
|
public default float getY() {
|
|
return getBox().getMinY();
|
|
}
|
|
|
|
public default float getWidth() {
|
|
return getBox().getWidth();
|
|
}
|
|
|
|
public default float getHeight() {
|
|
return getBox().getHeight();
|
|
}
|
|
|
|
public ILayoutComponent set(float x, float y);
|
|
public ILayoutComponent bounds(float width, float height);
|
|
public ILayoutComponent resize(float width, float height);
|
|
public ILayoutComponent move(float moveX, float moveY);
|
|
|
|
public static interface ILayoutScanner {
|
|
public default void accept(IGuiBox box) { accept(box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY()); }
|
|
public void accept(float minX, float minY, float maxX, float maxY);
|
|
public boolean acceptsInvisble();
|
|
|
|
public static ArrayFetcher of() { return new ArrayFetcher(false); }
|
|
public static ArrayFetcher includeInvisible() { return new ArrayFetcher(true); }
|
|
}
|
|
|
|
public static class ArrayFetcher implements ILayoutScanner {
|
|
float[] result = new float[] {Float.MAX_VALUE, Float.MAX_VALUE, -Float.MAX_VALUE, -Float.MAX_VALUE};
|
|
boolean includeInvisible = false;
|
|
|
|
public ArrayFetcher(boolean includeInvisible) {
|
|
this.includeInvisible = includeInvisible;
|
|
}
|
|
|
|
@Override
|
|
public boolean acceptsInvisble() {
|
|
return includeInvisible;
|
|
}
|
|
|
|
@Override
|
|
public void accept(float minX, float minY, float maxX, float maxY) {
|
|
result[0] = Math.min(minX, result[0]);
|
|
result[1] = Math.min(minX, result[1]);
|
|
result[2] = Math.max(minX, result[2]);
|
|
result[3] = Math.max(minX, result[3]);
|
|
}
|
|
|
|
public float[] getResult() {
|
|
return result;
|
|
}
|
|
}
|
|
}
|