Create some GUI text methods

This commit is contained in:
2021-03-11 11:26:31 +01:00
parent f7bed7a045
commit 54d428245f
3 changed files with 81 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
package com.bartlomiejpluta.base.api.game.gui;
public class Bounds {
private float minX;
private float minY;
private float maxX;
private float maxY;
public void update(float minX, float minY, float maxX, float maxY) {
this.minX = minX;
this.minY = minY;
this.maxX = maxX;
this.maxY = maxY;
}
public float getMinX() {
return minX;
}
public float getMinY() {
return minY;
}
public float getMaxX() {
return maxX;
}
public float getMaxY() {
return maxY;
}
public float getWidth() {
return maxX - minX;
}
public float getHeight() {
return maxY - minY;
}
}

View File

@@ -4,6 +4,14 @@ import com.bartlomiejpluta.base.api.internal.gc.Disposable;
import com.bartlomiejpluta.base.api.internal.render.Renderable;
public interface GUI extends Renderable, Disposable {
int ALIGN_LEFT = 1 << 0;
int ALIGN_CENTER = 1 << 1;
int ALIGN_RIGHT = 1 << 2;
int ALIGN_TOP = 1 << 3;
int ALIGN_MIDDLE = 1 << 4;
int ALIGN_BOTTOM = 1 << 5;
int ALIGN_BASELINE = 1 << 6;
Widget getRoot();
void setRoot(Widget root);
@@ -20,5 +28,13 @@ public interface GUI extends Renderable, Disposable {
void setFontSize(float size);
void setTextAlignment(int alignment);
void putText(float x, float y, CharSequence text, Bounds outTextBounds);
void putText(float x, float y, CharSequence text);
void putTextBox(float x, float y, float lineWidth, CharSequence text, Bounds outTextBoxBounds);
void putTextBox(float x, float y, float lineWidth, CharSequence text);
}