[Feature] Line Seperators
This commit is contained in:
parent
20c89735ce
commit
fab4107dbe
5 changed files with 99 additions and 7 deletions
|
@ -117,7 +117,7 @@ public abstract class AbstractStack<R extends ComponentRenderer, T extends Abstr
|
|||
public void setFocused(@Nullable GuiEventListener guiEventListener) {
|
||||
focused = guiEventListener;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Image addIcon(ResourceLocation location, Size resourceSize) {
|
||||
Image i = new Image(Value.fixed(24), Value.fixed(24), location, resourceSize);
|
||||
|
@ -234,5 +234,17 @@ public abstract class AbstractStack<R extends ComponentRenderer, T extends Abstr
|
|||
add(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
public HLine addHLine(Value width, Value height) {
|
||||
HLine l = new HLine(width, height);
|
||||
add(l);
|
||||
return l;
|
||||
}
|
||||
|
||||
public VLine addVLine(Value width, Value height) {
|
||||
VLine l = new VLine(width, height);
|
||||
add(l);
|
||||
return l;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,9 +39,4 @@ public class ColorPicker extends HorizontalStack {
|
|||
public int getContentHeight() {
|
||||
return Math.max(swatch.getContentHeight(), input.getContentHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean changeFocus(boolean bl) {
|
||||
return input.changeFocus(bl);
|
||||
}
|
||||
}
|
||||
|
|
40
src/main/java/org/betterx/ui/layout/components/HLine.java
Normal file
40
src/main/java/org/betterx/ui/layout/components/HLine.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
package org.betterx.ui.layout.components;
|
||||
|
||||
import org.betterx.ui.ColorUtil;
|
||||
import org.betterx.ui.layout.components.render.RenderHelper;
|
||||
import org.betterx.ui.layout.values.Alignment;
|
||||
import org.betterx.ui.layout.values.Rectangle;
|
||||
import org.betterx.ui.layout.values.Value;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
public class HLine extends CustomRenderComponent {
|
||||
private int color = ColorUtil.WHITE;
|
||||
|
||||
public HLine(Value width, Value height) {
|
||||
super(width, height);
|
||||
}
|
||||
|
||||
public HLine setColor(int color) {
|
||||
this.color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customRender(PoseStack stack, int x, int y, float deltaTicks, Rectangle bounds, Rectangle clipRect) {
|
||||
int top = bounds.height - getContentHeight();
|
||||
if (vAlign == Alignment.CENTER) top /= 2;
|
||||
else if (vAlign == Alignment.MIN) top = 0;
|
||||
RenderHelper.hLine(stack, 0, bounds.width, top, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContentWidth() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContentHeight() {
|
||||
return 1;
|
||||
}
|
||||
}
|
45
src/main/java/org/betterx/ui/layout/components/VLine.java
Normal file
45
src/main/java/org/betterx/ui/layout/components/VLine.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
package org.betterx.ui.layout.components;
|
||||
|
||||
import org.betterx.ui.ColorUtil;
|
||||
import org.betterx.ui.layout.components.render.RenderHelper;
|
||||
import org.betterx.ui.layout.values.Alignment;
|
||||
import org.betterx.ui.layout.values.Rectangle;
|
||||
import org.betterx.ui.layout.values.Value;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
public class VLine extends CustomRenderComponent {
|
||||
private int color = ColorUtil.WHITE;
|
||||
|
||||
public VLine(Value width, Value height) {
|
||||
super(width, height);
|
||||
}
|
||||
|
||||
public VLine setColor(int color) {
|
||||
this.color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customRender(PoseStack stack, int x, int y, float deltaTicks, Rectangle bounds, Rectangle clipRect) {
|
||||
int left = bounds.height - getContentHeight();
|
||||
if (hAlign == Alignment.CENTER) left /= 2;
|
||||
else if (hAlign == Alignment.MIN) left = 0;
|
||||
RenderHelper.vLine(stack, left, 0, bounds.height, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContentWidth() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getContentHeight() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMouseOver(double d, double e) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -49,7 +49,7 @@ public class RenderHelper {
|
|||
innerFill(transform, x0, y, x1 + 1, y + 1, color);
|
||||
}
|
||||
|
||||
protected static void vLine(PoseStack poseStack, int x, int y0, int y1, int color) {
|
||||
public static void vLine(PoseStack poseStack, int x, int y0, int y1, int color) {
|
||||
if (y1 < y0) {
|
||||
int m = y0;
|
||||
y0 = y1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue