padding cleanup

bottom-bar
Ivory 2023-01-29 23:43:39 -05:00
parent 2ff6b06588
commit 5374bcaaeb
2 changed files with 10 additions and 6 deletions

View File

@ -9,6 +9,7 @@ import java.util.Set;
import java.util.Stack; import java.util.Stack;
import xyz.valnet.engine.math.Box; import xyz.valnet.engine.math.Box;
import xyz.valnet.engine.math.Vector2f;
import xyz.valnet.engine.math.Vector2i; import xyz.valnet.engine.math.Vector2i;
import xyz.valnet.engine.math.Vector4i; import xyz.valnet.engine.math.Vector4i;
import xyz.valnet.engine.scenegraph.GameObject; import xyz.valnet.engine.scenegraph.GameObject;
@ -317,11 +318,11 @@ public abstract class ImmediateUI extends GameObject implements IMouseCaptureAre
protected void groupEnd() { protected void groupEnd() {
padEnd(); padEnd();
Drawing.setLayer(getPreviousLayer()); Box inner = context.box;
float h = context.box.h;
Assets.uiFrame.draw(context.box);
context = contextStack.pop(); context = contextStack.pop();
adjustBox(context.box.w, h); Drawing.setLayer(getCurrentLayer());
Assets.uiFrame.draw(inner);
adjustBox(inner.w, inner.h);
} }
protected void pad() { protected void pad() {
@ -348,9 +349,9 @@ public abstract class ImmediateUI extends GameObject implements IMouseCaptureAre
} }
protected void padEnd() { protected void padEnd() {
float h = context.box.h + 16; Box inner = context.box;
context = contextStack.pop(); context = contextStack.pop();
adjustBox(context.box.w + 16, h); adjustBox(inner.w + 16, inner.h + 16);
} }
protected void horizontal(RenderCallback cb) { protected void horizontal(RenderCallback cb) {

View File

@ -6,6 +6,7 @@ public class Box implements Serializable {
public final float x, y, w, h, x2, y2; public final float x, y, w, h, x2, y2;
public final Vector2f a, b; public final Vector2f a, b;
public final Vector2f pos, dim;
public static final Box none = new Box(0, 0, 0, 0); public static final Box none = new Box(0, 0, 0, 0);
@ -28,6 +29,8 @@ public class Box implements Serializable {
this.y2 = this.y + this.h; this.y2 = this.y + this.h;
this.a = new Vector2f(this.x, this.y); this.a = new Vector2f(this.x, this.y);
this.b = new Vector2f(this.x2, this.y2); this.b = new Vector2f(this.x2, this.y2);
this.pos = this.a;
this.dim = new Vector2f(this.w, this.h);
} }
public Box(Vector2f pos, float w, float h) { public Box(Vector2f pos, float w, float h) {