Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
fee80c1
feat(ui): add initial module setup for AnvilLib-Ui with dependencies …
Gu-ZT May 18, 2026
b6f2917
feat(ui): add TODO documentation for module.ui development phases and…
Gu-ZT May 18, 2026
90e4235
feat(ui): implement UI components including Button, Text, and layout …
Gu-ZT May 18, 2026
69fc07b
feat(ui): add DeclarativeTestScreen for end-to-end testing of declara…
Gu-ZT May 18, 2026
f497866
feat(ui): add UI components including Button, Column, Text, and modif…
Gu-ZT May 18, 2026
7316283
feat(ui): add alignment and arrangement classes for layout management…
Gu-ZT May 18, 2026
ca73b48
feat(ui): add @Nullable annotations to enhance null safety in UI comp…
Gu-ZT May 18, 2026
09f0162
feat(ui): add ImageComponent and SpacerComponent for enhanced UI layo…
Gu-ZT May 18, 2026
261ae3f
feat(ci): add rendering dependency to UI workflows for improved build…
Gu-ZT May 18, 2026
352b394
feat(ui): add modifier support to UI components and enhance backgroun…
Gu-ZT May 18, 2026
54a65a8
feat(ui): enhance ButtonComponent with precise rendering and hit testing
Gu-ZT May 18, 2026
0bc1363
feat(ui): fix text vertical alignment in ButtonComponent for improved…
Gu-ZT May 18, 2026
4fdbb59
feat(ui): fix text vertical alignment in ButtonComponent for improved…
Gu-ZT May 18, 2026
da0600c
feat(ui): optimize composition rendering and improve mouse click hand…
Gu-ZT May 18, 2026
cf83054
feat(ui): add Checkbox, Slider, and TextField components with input h…
Gu-ZT May 18, 2026
7d4f5da
feat(ui): implement Animatable for tick-driven animations and add Gri…
Gu-ZT May 18, 2026
29fb807
feat(ui): enhance DeclarativeTestScreen with comprehensive component …
Gu-ZT May 18, 2026
5db100b
feat(ui): refactor SliderComponent and TextFieldComponent to use simp…
Gu-ZT May 18, 2026
fcf3255
feat(ui): implement scroll handling in Composition and DeclarativeScr…
Gu-ZT May 18, 2026
abaa808
feat(ui): add ScrollableComponent for vertical scrolling and enhance …
Gu-ZT May 18, 2026
1e14960
feat(ui): update ButtonComponent and TextComponent to support drop sh…
Gu-ZT May 18, 2026
8ee7f96
feat(ui): enhance DeclarativeTestScreen with scrollable layout for im…
Gu-ZT May 18, 2026
4d45427
feat(ui): refactor DeclarativeTestScreen to utilize Scrollable for im…
Gu-ZT May 18, 2026
0d77eea
feat(ui): implement runtime state preservation for ScrollableComponen…
Gu-ZT May 18, 2026
a40ff8a
feat(ui): implement runtime state preservation for ScrollableComponen…
Gu-ZT May 18, 2026
ecb9b9d
feat(ui): enhance TextFieldComponent with state preservation and focu…
Gu-ZT May 18, 2026
a065ed7
feat(ui): refactor state management to use Ref instead of MutableStat…
Gu-ZT May 18, 2026
7d0b02b
feat(ui): simplify slider and text field value updates using method r…
Gu-ZT May 18, 2026
d189dd0
feat(ui): translate comments to Chinese for better localization
Gu-ZT May 18, 2026
21b7482
feat(ui): replace TextFieldComponent with TextInputComponent for impr…
Gu-ZT May 18, 2026
a1371f5
feat(ui): adjust ScrollableComponent layout to account for scrollbar …
Gu-ZT May 18, 2026
4376111
feat(ui): enhance ScrollableComponent with scrollbar drag functionality
Gu-ZT May 18, 2026
5b61aff
feat(ui): update TODO.md for improved clarity and localization
Gu-ZT May 18, 2026
da87c5d
feat(ui): improve SliderComponent value calculation to prevent divisi…
Gu-ZT May 18, 2026
4be4daf
feat(ui): simplify component constructors by removing onClick and onC…
Gu-ZT May 18, 2026
73d41de
feat(ui): simplify slider value management by using ref() instead of …
Gu-ZT May 18, 2026
79aea64
feat(ui): implement vModel two-way binding for Checkbox, Slider, and …
Gu-ZT May 18, 2026
e5f5a2b
feat(ui): add DropdownComponent for improved UI selection options
Gu-ZT May 18, 2026
2ec9a88
feat(ui): enhance DropdownComponent with popup scrolling and z-order …
Gu-ZT May 18, 2026
6de8ac0
feat(ui): add triangle rendering support to SDF graphics and components
Gu-ZT May 18, 2026
187b58f
feat(ui): refactor components to use fluent accessors and simplify me…
Gu-ZT May 18, 2026
bcff1c2
feat(ui): improve code readability by formatting comments and adjusti…
Gu-ZT May 18, 2026
84e6f19
feat(ui): improve code readability by formatting comments and adjusti…
Gu-ZT May 18, 2026
abbe2f3
feat(ui): clean up code by removing unnecessary blank lines and impro…
Gu-ZT May 18, 2026
fbafa91
feat(ui): enhance null safety by adding nullable annotations and adju…
Gu-ZT May 18, 2026
1a26c80
feat(ui): add @SuppressWarnings annotations to suppress unused variab…
Gu-ZT May 18, 2026
1f4fec1
feat(ui): enhance code consistency by using 'this' keyword for instan…
Gu-ZT May 18, 2026
def17f9
feat(ui): improve code consistency by using 'this' keyword for instan…
Gu-ZT May 18, 2026
2b74d03
feat(ui): enhance null safety by adding NonNull annotations and refin…
Gu-ZT May 18, 2026
bfa1ef0
feat(ui): implement mouse interaction for UI components with click an…
Gu-ZT May 19, 2026
30704e1
feat(ui): enhance mouse event handling by introducing event priority …
Gu-ZT May 19, 2026
13f9e06
feat(ui): implement rendering priority for UI components and sort chi…
Gu-ZT May 19, 2026
a1f328f
feat(ui): add toggle command for SDF layer rendering and update compo…
Gu-ZT May 19, 2026
5d34133
feat(ui): add sound feedback for UI component interactions and enhanc…
Gu-ZT May 19, 2026
9303b1c
feat(ui): add hover highlight for dropdown items and improve backgrou…
Gu-ZT May 19, 2026
6d677ec
feat(ui): implement hover state update method for UI components
Gu-ZT May 19, 2026
b7d1406
feat(ui): refactor hover state handling and improve code formatting i…
Gu-ZT May 19, 2026
02b36a4
feat(ui): fix scrollbar position calculations in DropdownComponent an…
Gu-ZT May 19, 2026
20d68d9
feat(ui): add dragging state to SliderComponent and update mouse even…
Gu-ZT May 19, 2026
08549b5
feat(ui): streamline runtime state copying in UI components
Gu-ZT May 19, 2026
bb72491
feat(ui): enhance TextInputComponent with cursor scrolling and displa…
Gu-ZT May 19, 2026
cf35327
feat(ui): enhance TextInputComponent with text selection and improved…
Gu-ZT May 19, 2026
cc555f3
feat(ui): update TODO.md with component status and recent enhancements
Gu-ZT May 19, 2026
fba6d3b
feat(ui): implement FlexComponent and FlexScope for flexible layout m…
Gu-ZT May 19, 2026
c83b698
feat(ui): add LazyColumnComponent for virtualized vertical lists with…
Gu-ZT May 19, 2026
d491427
feat(ui): optimize component initialization and enhance resizing beha…
Gu-ZT May 19, 2026
7e60dca
feat(ui): refactor Ref class methods for improved state management an…
Gu-ZT May 19, 2026
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
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,33 @@ jobs:
signing_key: ${{ secrets.SIGNING_KEY }}
signing_public_key: ${{ secrets.SIGNING_PUBLIC_KEY }}
signing_password: ${{ secrets.SIGNING_PASSWORD }}
ui:
needs:
- rendering
uses: ./.github/workflows/build_and_test.yml
with:
module: ui
module_id: anvillib-ui
mod_id: anvillib_ui
ci_build: true
pr_build: false
secrets:
maven_url: ${{ secrets.MAVEN_URL }}
maven_user: ${{ secrets.MAVEN_USER }}
maven_pass: ${{ secrets.MAVEN_PASS }}
ui-maven-central-deploy:
uses: ./.github/workflows/publish_maven_central.yml
needs:
- ui
with:
module: ui
module_id: anvillib-ui
secrets:
maven_central_username: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
maven_central_password: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
signing_key: ${{ secrets.SIGNING_KEY }}
signing_public_key: ${{ secrets.SIGNING_PUBLIC_KEY }}
signing_password: ${{ secrets.SIGNING_PASSWORD }}
util:
uses: ./.github/workflows/build_and_test.yml
needs:
Expand Down Expand Up @@ -426,6 +453,7 @@ jobs:
- rendering
- space-select
- sync
- ui
- util
- wheel
uses: ./.github/workflows/build_and_test.yml
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ jobs:
mod_id: anvillib_sync
ci_build: true
pr_build: true
ui:
needs:
- rendering
uses: ./.github/workflows/build_and_test.yml
with:
module: ui
module_id: anvillib-ui
mod_id: anvillib_ui
ci_build: true
pr_build: true
util:
uses: ./.github/workflows/build_and_test.yml
needs:
Expand Down Expand Up @@ -171,6 +181,7 @@ jobs:
- rendering
- space-select
- sync
- ui
- util
- wheel
uses: ./.github/workflows/build_and_test.yml
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,33 @@ jobs:
signing_key: ${{ secrets.SIGNING_KEY }}
signing_public_key: ${{ secrets.SIGNING_PUBLIC_KEY }}
signing_password: ${{ secrets.SIGNING_PASSWORD }}
ui:
needs:
- rendering
uses: ./.github/workflows/build_and_test.yml
with:
module: ui
module_id: anvillib-ui
mod_id: anvillib_ui
ci_build: false
pr_build: false
secrets:
maven_url: ${{ secrets.MAVEN_URL }}
maven_user: ${{ secrets.MAVEN_USER }}
maven_pass: ${{ secrets.MAVEN_PASS }}
ui-maven-central-deploy:
uses: ./.github/workflows/publish_maven_central.yml
needs:
- ui
with:
module: ui
module_id: anvillib-ui
secrets:
maven_central_username: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
maven_central_password: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
signing_key: ${{ secrets.SIGNING_KEY }}
signing_public_key: ${{ secrets.SIGNING_PUBLIC_KEY }}
signing_password: ${{ secrets.SIGNING_PASSWORD }}
util:
uses: ./.github/workflows/build_and_test.yml
needs:
Expand Down Expand Up @@ -426,6 +453,7 @@ jobs:
- rendering
- space-select
- sync
- ui
- util
- wheel
uses: ./.github/workflows/build_and_test.yml
Expand Down
2 changes: 2 additions & 0 deletions module.main/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies {
jarJar(api("dev.anvilcraft.lib:anvillib-rendering-neoforge-26.1:latest.release"))
jarJar(api("dev.anvilcraft.lib:anvillib-space-select-neoforge-26.1:latest.release"))
jarJar(api("dev.anvilcraft.lib:anvillib-sync-neoforge-26.1:latest.release"))
jarJar(api("dev.anvilcraft.lib:anvillib-ui-neoforge-26.1:latest.release"))
jarJar(api("dev.anvilcraft.lib:anvillib-util-neoforge-26.1:latest.release"))
jarJar(api("dev.anvilcraft.lib:anvillib-wheel-neoforge-26.1:latest.release"))
} else {
Expand All @@ -35,6 +36,7 @@ dependencies {
jarJar(implementation project(":anvillib-rendering-neoforge-26.1"))
jarJar(implementation project(":anvillib-space-select-neoforge-26.1"))
jarJar(implementation project(":anvillib-sync-neoforge-26.1"))
jarJar(implementation project(":anvillib-ui-neoforge-26.1"))
jarJar(implementation project(":anvillib-util-neoforge-26.1"))
jarJar(implementation project(":anvillib-wheel-neoforge-26.1"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ public static float sd(
shape.x, shape.y,
shape.z
);

case TRIANGLE -> sdTriangle(
px, py,
shape.x, shape.y,
shape.z, shape.w,
Float.intBitsToFloat(params.getTypeParams().w),
params.getSharedParams().w
);
};

if (params.isOnion()) {
Expand Down Expand Up @@ -259,4 +267,39 @@ public static float sdEgg(
) - (ce + ra);
}

/**
* 三角形 SDF。来自 <a href="https://iquilezles.org/articles/distfunctions2d/">IQ</a>。
*/
public static float sdTriangle(
float px, float py,
float x0, float y0,
float x1, float y1,
float x2, float y2
) {
float ex0 = x1 - x0, ey0 = y1 - y0;
float ex1 = x2 - x1, ey1 = y2 - y1;
float ex2 = x0 - x2, ey2 = y0 - y2;
float e0x = px - x0, e0y = py - y0;
float e1x = px - x1, e1y = py - y1;
float e2x = px - x2, e2y = py - y2;

float v0 = e0x * ey0 - e0y * ex0;
float v1 = e1x * ey1 - e1y * ex1;
float v2 = e2x * ey2 - e2y * ex2;

float d;
if (v0 * v1 > 0.0f && v1 * v2 > 0.0f) {
d = -Math.min(Math.min(
(e0x * ex0 + e0y * ey0) / (float) Math.sqrt(ex0 * ex0 + ey0 * ey0),
(e1x * ex1 + e1y * ey1) / (float) Math.sqrt(ex1 * ex1 + ey1 * ey1)),
(e2x * ex2 + e2y * ey2) / (float) Math.sqrt(ex2 * ex2 + ey2 * ey2));
} else {
d = (float) Math.sqrt(Math.min(Math.min(
e0x * e0x + e0y * e0y,
e1x * e1x + e1y * e1y),
e2x * e2x + e2y * e2y));
}
return d;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ public SdfGraphics egg(
return this;
}

/** 三角形。按逆时针顺序填入三个顶点坐标。包围盒自动计算。 */
public SdfGraphics triangle(
float x0, float y0,
float x1, float y1,
float x2, float y2
) {
this.parameters.triangle(x0, y0, x1, y1, x2, y2);
return this;
}

public SdfGraphics color(int color) {
this.parameters .color(color);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ public void egg(float topRadius, float bottomRadius, float height) {
this.shapeParams .set(height, bottomRadius, topRadius, 0.0f);
}

/** 三角形。按逆时针顺序填入三个顶点坐标。顶点自动转为局部坐标。 */
public void triangle(float x0, float y0, float x1, float y1, float x2, float y2) {
this._renderType(SdfRenderType.TRIANGLE);
float minX = Math.min(Math.min(x0, x1), x2);
float minY = Math.min(Math.min(y0, y1), y2);
float maxX = Math.max(Math.max(x0, x1), x2);
float maxY = Math.max(Math.max(y0, y1), y2);
float cx = minX + (maxX - minX) / 2f;
float cy = minY + (maxY - minY) / 2f;
this.rect.set(minX, minY, maxX - minX, maxY - minY);
this.shapeParams.set(x0 - cx, y0 - cy, x1 - cx, y1 - cy);
this.typeParams.z = 0; // onion off
this.typeParams.w = Float.floatToIntBits(x2 - cx);
this.sharedParams.w = y2 - cy; // fill 模式下安全
}

public void smooth(float smooth) {
this ._smooth(smooth);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ public enum SdfRenderType {
SECTOR,
PIE,
CAPSULE,
EGG;
EGG,
TRIANGLE;

private static final SdfRenderType[] VALUES = values();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ layout(std140) uniform SDFParameters {
#define RT_PIE 4
#define RT_UCAPSULE 5
#define RT_EGG 6
#define RT_TRIANGLE 7

#define PASS_FILL 0
#define PASS_LIGHT 1
Expand Down Expand Up @@ -106,6 +107,31 @@ float sdEgg( in vec2 p, in float he, in float ra, in float rb )
return length(vec2(p.x+ce,p.y))-(ce+ra);
}

// from https://iquilezles.org/articles/distfunctions2d/
float sdTriangle( in vec2 p, in vec2 v0, in vec2 v1, in vec2 v2 )
{
vec2 e0 = v1 - v0, e1 = v2 - v1, e2 = v0 - v2;
vec2 vp0 = p - v0, vp1 = p - v1, vp2 = p - v2;

float s0 = vp0.x * e0.y - vp0.y * e0.x;
float s1 = vp1.x * e1.y - vp1.y * e1.x;
float s2 = vp2.x * e2.y - vp2.y * e2.x;

float d;
if (s0 * s1 > 0.0 && s1 * s2 > 0.0) {
d = -min(min(
dot(vp0, e0) / length(e0),
dot(vp1, e1) / length(e1)),
dot(vp2, e2) / length(e2));
} else {
d = sqrt(min(min(
dot(vp0, vp0),
dot(vp1, vp1)),
dot(vp2, vp2)));
}
return d;
}

void main() {
Sdf params = SDFs[vIndex];
vec4 shape = params.Shape;
Expand Down Expand Up @@ -135,6 +161,10 @@ void main() {
case RT_EGG:
d = sdEgg(p, shape.x, shape.y, shape.z);
break;
case RT_TRIANGLE:
d = sdTriangle(p, shape.xy, shape.zw,
vec2(intBitsToFloat(params.Types.w), params.Shared.w));
break;
}

float aa = max(fwidth(d) * 0.5, uSmoothRadius);
Expand Down
1 change: 1 addition & 0 deletions module.test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependencies {
implementation project(":anvillib-rendering-neoforge-26.1")
implementation project(":anvillib-space-select-neoforge-26.1")
implementation project(":anvillib-sync-neoforge-26.1")
implementation project(":anvillib-ui-neoforge-26.1")
implementation project(":anvillib-util-neoforge-26.1")
implementation project(":anvillib-wheel-neoforge-26.1")
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import dev.anvilcraft.lib.v2.test.all.TestTiles;
import dev.anvilcraft.lib.v2.test.client.cber.TestCachedRenderer;
import dev.anvilcraft.lib.v2.test.client.gui.SdfGraphicsLayer;
import dev.anvilcraft.lib.v2.test.client.screen.DeclarativeTestScreen;
import dev.anvilcraft.lib.v2.test.client.screen.GuiTestScreen;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.Commands;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
Expand All @@ -21,6 +21,8 @@
@EventBusSubscriber(modid = AnvilLibTest.MOD_ID)
@Mod(value = AnvilLibTest.MOD_ID, dist = Dist.CLIENT)
public class AnvilLibTestClient {
public static boolean renderSdfLayer = false;

public AnvilLibTestClient() {
}

Expand All @@ -46,6 +48,19 @@ public static void on(RegisterClientCommandsEvent event) {
Minecraft.getInstance().setScreen(new GuiTestScreen());
return 1;
})
).
then(
literal("declarative").
executes(_ -> {
Minecraft.getInstance().setScreen(new DeclarativeTestScreen());
return 1;
})
).then(
literal("sdf")
.executes(_ -> {
AnvilLibTestClient.renderSdfLayer = !AnvilLibTestClient.renderSdfLayer;
return 1;
})
)
);
}
Expand Down
Loading
Loading