More flexible Line Separators

This commit is contained in:
Frank 2022-07-19 19:56:22 +02:00
parent fab4107dbe
commit 200385c73e
4 changed files with 25 additions and 5 deletions

View file

@ -38,7 +38,7 @@ public class TestScreen extends LayoutScreen {
Component.literal("Some other, longer Text") Component.literal("Some other, longer Text")
).centerHorizontal() ).centerHorizontal()
); );
rows.addSpacer(16); rows.addHorizontalSeparator(16).alignTop();
rows.add(new Input(Value.fitOrFill(), Value.fit(), Component.literal("Input"), "0xff00ff")); rows.add(new Input(Value.fitOrFill(), Value.fit(), Component.literal("Input"), "0xff00ff"));
rows.add(new ColorSwatch(Value.fit(), Value.fit(), ColorUtil.LIGHT_PURPLE).centerHorizontal()); rows.add(new ColorSwatch(Value.fit(), Value.fit(), ColorUtil.LIGHT_PURPLE).centerHorizontal());
rows.add(new ColorPicker( rows.add(new ColorPicker(
@ -52,7 +52,7 @@ public class TestScreen extends LayoutScreen {
Component.literal("Some blue text") Component.literal("Some blue text")
).centerHorizontal().setColor(ColorUtil.BLUE) ).centerHorizontal().setColor(ColorUtil.BLUE)
); );
rows.addSpacer(16); rows.addHLine(Value.fixed(32), Value.fixed(16));
rows.add(new Image( rows.add(new Image(
Value.fixed(24), Value.fixed(24), Value.fixed(24), Value.fixed(24),
BCLib.makeID("icon.png"), BCLib.makeID("icon.png"),
@ -66,7 +66,7 @@ public class TestScreen extends LayoutScreen {
).setColor(ColorUtil.LIGHT_PURPLE).centerHorizontal() ).setColor(ColorUtil.LIGHT_PURPLE).centerHorizontal()
); );
rows.addSpacer(16); rows.addHorizontalLine(16);
rows.add(new Range<>( rows.add(new Range<>(
Value.fill(), Value.fit(), Value.fill(), Value.fit(),
Component.literal("Integer"), Component.literal("Integer"),

View file

@ -235,12 +235,28 @@ public abstract class AbstractStack<R extends ComponentRenderer, T extends Abstr
return c; return c;
} }
public HLine addHorizontalSeparator(int height) {
return addHLine(Value.relative(1.0 / 1.618033988749894), Value.fixed(height));
}
public HLine addHorizontalLine(int height) {
return addHLine(Value.fill(), Value.fixed(height));
}
public HLine addHLine(Value width, Value height) { public HLine addHLine(Value width, Value height) {
HLine l = new HLine(width, height); HLine l = new HLine(width, height);
add(l); add(l);
return l; return l;
} }
public VLine addVerticalSeparator(int width) {
return addVLine(Value.fixed(width), Value.relative(1.0 / 1.618033988749894));
}
public VLine addVerticalLine(int width) {
return addVLine(Value.fixed(width), Value.fill());
}
public VLine addVLine(Value width, Value height) { public VLine addVLine(Value width, Value height) {
VLine l = new VLine(width, height); VLine l = new VLine(width, height);
add(l); add(l);

View file

@ -9,10 +9,12 @@ import org.betterx.ui.layout.values.Value;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
public class HLine extends CustomRenderComponent { public class HLine extends CustomRenderComponent {
private int color = ColorUtil.WHITE; private int color = ColorUtil.DEFAULT_TEXT;
public HLine(Value width, Value height) { public HLine(Value width, Value height) {
super(width, height); super(width, height);
this.vAlign = Alignment.CENTER;
this.hAlign = Alignment.CENTER;
} }
public HLine setColor(int color) { public HLine setColor(int color) {

View file

@ -9,10 +9,12 @@ import org.betterx.ui.layout.values.Value;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
public class VLine extends CustomRenderComponent { public class VLine extends CustomRenderComponent {
private int color = ColorUtil.WHITE; private int color = ColorUtil.DEFAULT_TEXT;
public VLine(Value width, Value height) { public VLine(Value width, Value height) {
super(width, height); super(width, height);
this.vAlign = Alignment.CENTER;
this.hAlign = Alignment.CENTER;
} }
public VLine setColor(int color) { public VLine setColor(int color) {