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];
|
||||
}
|
||||
IGuiBox box = owner.getBox();
|
||||
totals[0] -= box.getBaseWidth();
|
||||
totals[1] -= box.getBaseHeight();
|
||||
totals[0] = box.getBaseWidth() - totals[0];
|
||||
totals[1] = box.getBaseHeight() - totals[1];
|
||||
if(totals[2] > 0F) {
|
||||
float scale = 1F / totals[2];
|
||||
for(int i = 0,m=children.size();i<m;i++) {
|
||||
|
@ -81,21 +81,24 @@ public class Constraints {
|
||||
|
||||
@Override
|
||||
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
|
||||
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 Weighted of(float weight) { return new Weighted(weight); }
|
||||
public static record Weighted(float weight, float padding, boolean inverted) implements ISimpleConstraint {
|
||||
public static Weighted of(float weight) { return new Weighted(weight, 0F, false); }
|
||||
|
||||
@Override
|
||||
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
|
||||
@ -134,7 +137,6 @@ public class Constraints {
|
||||
@Override
|
||||
public void fetch(GuiComponent owner, GuiComponent parent, Target target, ConstrainedContext 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 speiger.src.collections.objects.lists.ObjectArrayList;
|
||||
import speiger.src.coreengine.math.BitUtil;
|
||||
import speiger.src.coreengine.math.vector.ints.Vec4i;
|
||||
import speiger.src.coreengine.rendering.input.window.IWindowListener.Reason;
|
||||
import speiger.src.coreengine.rendering.input.window.WindowCallback.ReloadFunction;
|
||||
@ -62,6 +63,10 @@ public class Window {
|
||||
flags.setFlag(VSYNC, builder.vsync);
|
||||
flags.setFlag(CPU_FPS_CAP, builder.fpsCap);
|
||||
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_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);
|
||||
|
@ -8,9 +8,12 @@ import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.system.Callback;
|
||||
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.interfaces.Long2ObjectMap;
|
||||
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.window.WindowCallback.SimpleReloadFunction;
|
||||
|
||||
@ -149,6 +152,7 @@ public class WindowManager {
|
||||
public static class WindowBuilder {
|
||||
WindowManager manager;
|
||||
long monitor;
|
||||
LongList windowHints = new LongArrayList();
|
||||
VideoMode fullScreenTarget;
|
||||
String title = "";
|
||||
int width = 640;
|
||||
@ -249,6 +253,11 @@ public class WindowManager {
|
||||
return this;
|
||||
}
|
||||
|
||||
public WindowBuilder addCustomHint(int key, int value) {
|
||||
windowHints.add(BitUtil.toLong(key, value));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Window build() {
|
||||
return manager.create(this);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user