Repository navigation
重构 TabHeader - #7104
Merged
Merged
重构 TabHeader#7104
Conversation
Glavo
commented
Oct 27, 2026
Member
- 删除 TabControl
- 将不需要渲染标签页的功能拆分至 TabController 类
- 重构相关代码,优化内存占用与性能
Assisted-by: codex:gpt-6-astra
…emove null checks
Assisted-by: codex:gpt-6-astra
Assisted-by: codex:gpt-6-astra
Assisted-by: codex:gpt-6-astra
…or improved clarity and consistency
Assisted-by: codex:gpt-6-astra
…mapping and remove userData from TabItem
…n state Assisted-by: codex:gpt-6-astra
…e annotations from varargs
…jectProperty for selected tab management
…ms directly in the constructor
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Implicit content initialization causes unnecessary page creation and duplicate loads, and null tab arrays no longer follow the documented constructor behavior.
2 open issues
What changed in this PR
This PR separates tab selection and content lifecycle management from header rendering, reducing UI overhead for sidebar-driven pages.
Changes:
- Replaces
TabControlwithTabControllerand lightweightTabItemobjects. - Simplifies
TabHeaderlayout and selection-indicator animation. - Migrates tab consumers and adds explicit content clearing to
TransitionPane.
| File | Description |
|---|---|
HMCL/src/main/java/org/jackhuang/hmcl/ui/terracotta/TerracottaPage.java |
Migrates sidebar selection and lifecycle forwarding. |
HMCL/src/main/java/org/jackhuang/hmcl/ui/main/LauncherSettingsPage.java |
Migrates settings tabs to the controller. |
HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/WorldManagePage.java |
Updates world tabs and refresh iteration. |
HMCL/src/main/java/org/jackhuang/hmcl/ui/instances/GameInstancePage.java |
Migrates instance-management tab navigation. |
HMCL/src/main/java/org/jackhuang/hmcl/ui/download/DownloadPage.java |
Migrates download tabs and consolidates content factories. |
HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/TabItem.java |
Adds lightweight tab labels and lazy content storage. |
HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/TabHeader.java |
Simplifies rendering, layout, and indicator animation. |
HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/TabController.java |
Adds selection, content transitions, and lifecycle management. |
HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/TabControl.java |
Removes the former tab abstraction and selection model. |
HMCL/src/main/java/org/jackhuang/hmcl/ui/construct/AdvancedListBox.java |
Connects sidebar items to controller selection. |
HMCL/src/main/java/org/jackhuang/hmcl/ui/animation/TransitionPane.java |
Adds transition-safe content clearing. |
HMCL/src/main/java/org/jackhuang/hmcl/ui/account/CreateAccountPane.java |
Migrates account-method tabs and factory associations. |
Review effort: Balanced
| public TabController(@Nullable TransitionPane contentPane, TabItem<?> ... tabs) { | ||
| this.contentPane = contentPane; | ||
| this.tabs.addListener(this::tabsChanged); | ||
| this.tabs.setAll(tabs); |
Comment on lines
+51
to
+54
| public @Nullable T getNode() { | ||
| initializeIfNeeded(); | ||
| return node; | ||
| } |
Assisted-by: codex:gpt-6-astra
…backs Assisted-by: codex:gpt-6-astra
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
