feat(UI): add AnvilLib-Ui module for declarative UI library#35
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new module.ui subproject for an AnvilLib UI module and wires it into the build, test, main aggregator, and CI/release workflows.
Changes:
- Registers
module.uiin Gradle settings and adds basic module metadata/resources. - Adds the
AnvilLibUimod entrypoint and resource helper. - Includes the UI module in test/main dependencies and CI/release job matrices.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
settings.gradle |
Registers and names the new UI subproject. |
module.ui/build.gradle |
Adds the module build file. |
module.ui/gradle.properties |
Defines UI module metadata. |
module.ui/src/main/java/dev/anvilcraft/lib/v2/ui/AnvilLibUi.java |
Adds the UI module entrypoint. |
module.ui/src/main/java/dev/anvilcraft/lib/v2/ui/package-info.java |
Marks the UI package as null-marked. |
module.ui/src/main/resources/META-INF/neoforge.mods.toml |
Adds NeoForge mod metadata. |
module.ui/src/main/resources/anvillib_ui.mixins.json |
Adds an empty mixin config for the module. |
module.test/build.gradle |
Adds UI as a test module dependency. |
module.main/build.gradle |
Bundles UI into the main AnvilLib artifact. |
.github/workflows/ci.yml |
Adds UI to CI build/deploy flow. |
.github/workflows/release.yml |
Adds UI to release build/deploy flow. |
.github/workflows/pull_request.yml |
Adds UI to PR checks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 40 out of 41 changed files in this pull request and generated 33 comments.
Comments suppressed due to low confidence (1)
module.ui/src/main/java/dev/anvilcraft/lib/v2/ui/UIScope.java:51
- Any state read used to compute the button label is evaluated before the button is emitted, so it cannot be tracked against the button's slot. Dynamic labels based on
MutableStatewill not reliably trigger recomposition.
Composition.current().emit(c);
return c;
}
| for (Composition.Slot slot : readers) { | ||
| slot.markDirty(); |
| extractor.centeredText(font, comp, (int) (x + width / 2), (int) (y + (height - font.lineHeight) / 2), TEXT_COLOR); | ||
| } | ||
|
|
||
| void click() { |
| Composition comp = Composition.currentOrNull(); | ||
| if (comp != null && comp.currentSlot != null) { | ||
| comp.currentSlot.addReadState(this); | ||
| readers.add(comp.currentSlot); | ||
| } |
| static ModifierElement width(float w) { | ||
| return new SizeElement(0, Float.MAX_VALUE, w, w); | ||
| } |
| static ModifierElement height(float h) { | ||
| return new SizeElement(h, 0, h, Float.MAX_VALUE); | ||
| } |
| ui: | ||
| 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 }} |
| public MeasuredSize measure(Constraints constraints) { | ||
| if (children.isEmpty()) return MeasuredSize.ZERO; | ||
|
|
| constraints.constrainWidth(maxWidth), | ||
| constraints.constrainHeight(totalHeight) | ||
| ); | ||
| } | ||
|
|
| this.width = width; | ||
| this.height = height; | ||
|
|
||
| List<Float> heights = new ArrayList<>(childSizes.size()); |
| } | ||
|
|
||
| // ── component builders ── | ||
|
|
…and CI configuration
…tive UI components
…iers for layout and styling
… in UI components
…d and border elements
…dComponent for grid layout
…tests and update Slider/TextField components to use Consumer for change handling
…lified Consumer type for change handling
…een for improved rendering
…DeclarativeScreen with scroll handling
…adow in text rendering
…proved component organization
…ldren accordingly
…nent measurement logic
…e hover state handling
…nd color handling
…d update mod name formatting
…y position management
… scrolling support
…d update UI components to use new method signatures
# Conflicts: # .github/workflows/ci.yml # .github/workflows/pull_request.yml # .github/workflows/release.yml # module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/sdf/Sdf2d.java # module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/sdf/SdfParameters.java # module.rendering/src/main/java/dev/anvilcraft/lib/v2/rendering/sdf/SdfRenderType.java # module.rendering/src/main/resources/assets/anvillib_rendering/shaders/core/sdf_graphics.fsh # module.test/src/main/java/dev/anvilcraft/lib/v2/test/client/AnvilLibTestClient.java # module.test/src/main/java/dev/anvilcraft/lib/v2/test/client/gui/SdfGraphicsLayer.java # settings.gradle
|
❌ Non-retryable error (HTTP 402): HTTP 402: Insufficient Balance |
|
|
🌿 Roseau API Breaking Change Report
|
- 将 Animatable 从基于 tick 的动画改为帧时间驱动的通用补间动画 - 添加插值器、缓动函数和动画配置选项(重复、延迟、yoyo等) - 重写布局系统使用 LayoutHelper 统一处理子组件测量、布局和渲染 - 为所有容器组件(Box、Column、Flex、Grid、LazyColumn)实现新的布局机制 - 修复排列算法中的负间隙计算问题 - 优化虚化列表的缓存和渲染性能 - 为下拉组件添加事件优先级和运行状态复制功能 - 新增填充修饰符元素和颜色插值器
- 在SdfGraphics单例上调用reset方法清除上次绘制的stroke/onion等残留状态 - 将非居中模式的box坐标转换为以矩形中心为原点的居中模式坐标 - 使用bounds中心点坐标替代原始左上角坐标进行box绘制 - 显式设置center(true)确保正确的居中渲染行为
- 修复按钮组件在有自定义修饰符时不绘制默认背景色的问题 - 在下拉组件箭头渲染前添加重置操作避免状态污染 - 确保UI组件渲染状态的一致性
- 在triangle方法中添加了坐标更新逻辑 - 确保绘制后图形位置参数正确同步 - 修复了由于坐标未及时更新导致的渲染偏差
- 使用LayoutHelper.renderChildrenSorted方法替代手动循环渲染子组件 - 在Composition类中按renderingPriority对根作用域子组件进行排序渲染 - 在DeclarativeScreen类中按eventPriority对鼠标事件处理组件进行倒序排序 - 添加新的renderChildrenSorted方法支持按渲染优先级排序渲染 - 移除多个组件类中的重复循环渲染代码,统一使用工具方法
- 修复滚动条拖拽区域判断逻辑,确保在整个滚动条区域内都能响应点击 - 优化滚动条拖拽锚点计算,在非滑块区域点击时自动定位到滑块中心 - 改进滚动位置计算公式,使滚动行为更加平滑准确 - 移除过时的滚动条高度和位置计算代码,简化交互逻辑
- 添加了 Minecraft 客户端实例导入 - 将 closeAllDropdowns 方法重命名为 closeUnrelatedDropdowns - 实现了仅关闭鼠标点击区域外的下拉组件功能 - 添加了鼠标坐标获取和碰撞检测逻辑 - 修改了鼠标点击事件处理流程,先分发事件再关闭无关下拉组件 - 更新了递归方法以支持坐标参数传递和精确的下拉状态控制
|
现在我已收集足够的数据。以下是完整的审查报告。 代码审查摘要PR #35 | 结论: COMMENT — 质量优良的新模块引入,架构设计清晰。发现 1 个需注意的配置问题 + 4 个需修复的格式问题。 🔴 关键(无)
|
🌿 Roseau API Breaking Change Report
|
No description provided.