Redesign the mod menu
The mod menu is now a translucent panel beside a navigation rail, with a header showing how many mods are enabled, a search box, category filters built from the mods' tags and a three-column grid of mod cards. Each card shows the mod's icon, name and description with a settings button and an on/off switch. The layout shrinks to fit smaller windows. New reusable pieces: Panel, Label, ChipGroup, SearchInput, Toggle.drawSwitch, Theme helpers for panel, border, muted text and body font, and Fonts.ellipsize. The sidebar and card icons are Lucide SVGs, and seven mod icons were redrawn in the same style. Scroll can skip its background and be cleared, and no longer passes clicks outside its bounds to children scrolled out of view. Input checks overflow and places the cursor at the scale its text is drawn at. Screens that are not redesigned yet move the wider sidebar so it keeps its gap. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -17,6 +17,7 @@ public class Scroll extends Element {
|
||||
private static IntProperty scrollBarPadding = Property.integer(5);
|
||||
|
||||
int padding = 0;
|
||||
boolean background = true;
|
||||
|
||||
protected List<Element> children = new ArrayList<>();
|
||||
int scroll = 0;
|
||||
@@ -30,12 +31,31 @@ public class Scroll extends Element {
|
||||
ElementRenderer.draw(children, element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Skips the scroll's own background, for when it sits on a {@link Panel}.
|
||||
*/
|
||||
public Scroll noBackground() {
|
||||
this.background = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes every child and scrolls back to the top.
|
||||
*/
|
||||
public void clear() {
|
||||
children.clear();
|
||||
scroll = 0;
|
||||
maxScroll = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(RenderScope renderScope, ElementContext ctx) {
|
||||
calculateMaxScroll();
|
||||
|
||||
renderScope.drawRoundedRectangle(0, 0, width, height,
|
||||
Theme.BG_RADIUS.value, Theme.BACKGROUND.value);
|
||||
if (background) {
|
||||
renderScope.drawRoundedRectangle(0, 0, width, height,
|
||||
Theme.BG_RADIUS.value, Theme.BACKGROUND.value);
|
||||
}
|
||||
|
||||
renderScope.enableScissor(padding, padding, width - padding, height - padding);
|
||||
renderScope.getMatrixStack().push();
|
||||
@@ -117,6 +137,15 @@ public class Scroll extends Element {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(double mouseX, double mouseY, int button) {
|
||||
// Children scrolled out of view still have positions under the rest of the
|
||||
// screen, so only clicks inside the scroll's own bounds may reach them.
|
||||
if (mouseX < 0 || mouseY < 0 || mouseX > width || mouseY > height) {
|
||||
for (Element child : children) {
|
||||
child.focused = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ElementRenderer.mouseClicked(children, mouseX - padding, mouseY - padding + scroll, button);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user