Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/main/java/com/cleanroommc/modularui/test/TestGuis.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
import java.util.Comparator;
import java.util.List;
import java.util.Random;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

Expand Down Expand Up @@ -761,6 +762,43 @@ public static ModularPanel buildContextMenu() {
.usingScrollStep()));
}

public static @NotNull ModularPanel buildCoverChildrenDraggableUI() {
int minSize = 8;

ParentWidget<?> draggableParent = new ParentWidget<>()
.coverChildren(minSize)
.marginTop(18);

ParentWidget<?> subParent = new ParentWidget<>();

// subParent = Flow.col().center();

Supplier<DraggableWidget<?>> draggableSupplier = () -> new DraggableWidget<>().size(18).background(GuiTextures.MC_BUTTON);

return ModularPanel.defaultPanel("main")
.size(500)
.child(subParent
.coverChildren()
.child(Flow.row()
.coverChildrenHeight()
.fullWidth()
.mainAxisAlignment(Alignment.MainAxis.SPACE_BETWEEN)
.child(new ButtonWidget<>().overlay(GuiTextures.REMOVE)
.onMousePressed(i -> {
if (!draggableParent.getChildren().isEmpty())
draggableParent.remove(0);
return true;
}))
.child(new ButtonWidget<>().overlay(GuiTextures.ADD)
.onMousePressed(i -> {
draggableParent.child(draggableSupplier.get());
return true;
})))
.child(draggableParent
.child(draggableSupplier.get())
.child(draggableSupplier.get())));
}

private static Rectangle rndRect(IntList colors, Random random) {
int i = random.nextInt(colors.size());
int c = colors.removeInt(i);
Expand Down