New window hints and a few fixes
This commit is contained in:
parent
dce550da0d
commit
6c4e036e46
@ -33,8 +33,8 @@ public class ConstrainedContext {
|
|||||||
totals[3] += weights[i*2+1];
|
totals[3] += weights[i*2+1];
|
||||||
}
|
}
|
||||||
IGuiBox box = owner.getBox();
|
IGuiBox box = owner.getBox();
|
||||||
totals[0] -= box.getBaseWidth();
|
totals[0] = box.getBaseWidth() - totals[0];
|
||||||
totals[1] -= box.getBaseHeight();
|
totals[1] = box.getBaseHeight() - totals[1];
|
||||||
if(totals[2] > 0F) {
|
if(totals[2] > 0F) {
|
||||||
float scale = 1F / totals[2];
|
float scale = 1F / totals[2];
|
||||||
for(int i = 0,m=children.size();i<m;i++) {
|
for(int i = 0,m=children.size();i<m;i++) {
|
||||||
|
@ -81,21 +81,24 @@ public class Constraints {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(IGuiBox owner, IGuiBox parent, Target target, ConstrainedContext context) {
|
public void apply(IGuiBox owner, IGuiBox parent, Target target, ConstrainedContext context) {
|
||||||
target.set(owner, value * (target.asArea().get(parent) - padding));
|
float result = value * target.asArea().get(parent);
|
||||||
|
target.set(owner, target.isPosition() ? result + padding : result - padding * 2F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fetch(IGuiBox owner, IGuiBox parent, Target target, ConstrainedContext context) {
|
public void fetch(IGuiBox owner, IGuiBox parent, Target target, ConstrainedContext context) {
|
||||||
context.addBound(value * (target.asArea().get(parent) - padding), target.isXAxis());
|
context.addBound(value * target.asArea().get(parent), target.isXAxis());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static record Weighted(float weight) implements ISimpleConstraint {
|
public static record Weighted(float weight, float padding, boolean inverted) implements ISimpleConstraint {
|
||||||
public static Weighted of(float weight) { return new Weighted(weight); }
|
public static Weighted of(float weight) { return new Weighted(weight, 0F, false); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(IGuiBox owner, IGuiBox parent, Target target, ConstrainedContext context) {
|
public void apply(IGuiBox owner, IGuiBox parent, Target target, ConstrainedContext context) {
|
||||||
target.set(owner, target.get(context));
|
float value = target.get(context);
|
||||||
|
if(inverted) target.set(owner, target.isPosition() ? target.asArea().get(parent) - value - padding : value - padding * 2);
|
||||||
|
else target.set(owner, target.isPosition() ? value + padding : value - padding * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -130,11 +133,10 @@ public class Constraints {
|
|||||||
public void apply(GuiComponent owner, GuiComponent parent, Target target, ConstrainedContext context) {
|
public void apply(GuiComponent owner, GuiComponent parent, Target target, ConstrainedContext context) {
|
||||||
(supplier.getAsBoolean() ? onTrue : onFalse).apply(owner, parent, target, context);
|
(supplier.getAsBoolean() ? onTrue : onFalse).apply(owner, parent, target, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fetch(GuiComponent owner, GuiComponent parent, Target target, ConstrainedContext context) {
|
public void fetch(GuiComponent owner, GuiComponent parent, Target target, ConstrainedContext context) {
|
||||||
(supplier.getAsBoolean() ? onTrue : onFalse).fetch(owner, parent, target, context);
|
(supplier.getAsBoolean() ? onTrue : onFalse).fetch(owner, parent, target, context);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import org.lwjgl.opengl.GLCapabilities;
|
|||||||
import org.lwjgl.system.CallbackI;
|
import org.lwjgl.system.CallbackI;
|
||||||
|
|
||||||
import speiger.src.collections.objects.lists.ObjectArrayList;
|
import speiger.src.collections.objects.lists.ObjectArrayList;
|
||||||
|
import speiger.src.coreengine.math.BitUtil;
|
||||||
import speiger.src.coreengine.math.vector.ints.Vec4i;
|
import speiger.src.coreengine.math.vector.ints.Vec4i;
|
||||||
import speiger.src.coreengine.rendering.input.window.IWindowListener.Reason;
|
import speiger.src.coreengine.rendering.input.window.IWindowListener.Reason;
|
||||||
import speiger.src.coreengine.rendering.input.window.WindowCallback.ReloadFunction;
|
import speiger.src.coreengine.rendering.input.window.WindowCallback.ReloadFunction;
|
||||||
@ -62,6 +63,10 @@ public class Window {
|
|||||||
flags.setFlag(VSYNC, builder.vsync);
|
flags.setFlag(VSYNC, builder.vsync);
|
||||||
flags.setFlag(CPU_FPS_CAP, builder.fpsCap);
|
flags.setFlag(CPU_FPS_CAP, builder.fpsCap);
|
||||||
createDefaultWindowHints();
|
createDefaultWindowHints();
|
||||||
|
for(int i = 0,m=builder.windowHints.size();i<m;i++) {
|
||||||
|
long value = builder.windowHints.getLong(i);
|
||||||
|
GLFW.glfwWindowHint(BitUtil.intKey(value), BitUtil.intValue(value));
|
||||||
|
}
|
||||||
GLFW.glfwWindowHint(GLFW.GLFW_SAMPLES, antialiasing);
|
GLFW.glfwWindowHint(GLFW.GLFW_SAMPLES, antialiasing);
|
||||||
GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, flags.isFlagSet(RESIZABLE) ? GLFW.GLFW_TRUE : GLFW.GLFW_FALSE);
|
GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, flags.isFlagSet(RESIZABLE) ? GLFW.GLFW_TRUE : GLFW.GLFW_FALSE);
|
||||||
GLFW.glfwWindowHint(GLFW.GLFW_DECORATED, flags.isFlagNotSet(FULL_SCREEN) && flags.isFlagSet(BORDERLESS) ? GLFW.GLFW_FALSE : GLFW.GLFW_TRUE);
|
GLFW.glfwWindowHint(GLFW.GLFW_DECORATED, flags.isFlagNotSet(FULL_SCREEN) && flags.isFlagSet(BORDERLESS) ? GLFW.GLFW_FALSE : GLFW.GLFW_TRUE);
|
||||||
|
@ -8,9 +8,12 @@ import org.lwjgl.glfw.GLFW;
|
|||||||
import org.lwjgl.system.Callback;
|
import org.lwjgl.system.Callback;
|
||||||
import org.lwjgl.system.CallbackI;
|
import org.lwjgl.system.CallbackI;
|
||||||
|
|
||||||
|
import speiger.src.collections.longs.lists.LongArrayList;
|
||||||
|
import speiger.src.collections.longs.lists.LongList;
|
||||||
import speiger.src.collections.longs.maps.impl.concurrent.Long2ObjectConcurrentOpenHashMap;
|
import speiger.src.collections.longs.maps.impl.concurrent.Long2ObjectConcurrentOpenHashMap;
|
||||||
import speiger.src.collections.longs.maps.interfaces.Long2ObjectMap;
|
import speiger.src.collections.longs.maps.interfaces.Long2ObjectMap;
|
||||||
import speiger.src.collections.objects.lists.ObjectArrayList;
|
import speiger.src.collections.objects.lists.ObjectArrayList;
|
||||||
|
import speiger.src.coreengine.math.BitUtil;
|
||||||
import speiger.src.coreengine.rendering.input.devices.InputDevice;
|
import speiger.src.coreengine.rendering.input.devices.InputDevice;
|
||||||
import speiger.src.coreengine.rendering.input.window.WindowCallback.SimpleReloadFunction;
|
import speiger.src.coreengine.rendering.input.window.WindowCallback.SimpleReloadFunction;
|
||||||
|
|
||||||
@ -149,6 +152,7 @@ public class WindowManager {
|
|||||||
public static class WindowBuilder {
|
public static class WindowBuilder {
|
||||||
WindowManager manager;
|
WindowManager manager;
|
||||||
long monitor;
|
long monitor;
|
||||||
|
LongList windowHints = new LongArrayList();
|
||||||
VideoMode fullScreenTarget;
|
VideoMode fullScreenTarget;
|
||||||
String title = "";
|
String title = "";
|
||||||
int width = 640;
|
int width = 640;
|
||||||
@ -248,6 +252,11 @@ public class WindowManager {
|
|||||||
fpsCap = cap;
|
fpsCap = cap;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WindowBuilder addCustomHint(int key, int value) {
|
||||||
|
windowHints.add(BitUtil.toLong(key, value));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Window build() {
|
public Window build() {
|
||||||
return manager.create(this);
|
return manager.create(this);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user