Skip to content

重构 TabHeader - #7104

Merged
Glavo merged 25 commits into
HMCL-dev:mainfrom
Glavo:tab-header
Oct 27, 2026
Merged

Glavo merged 25 commits into
HMCL-dev:mainfrom
Glavo:tab-header

Conversation

@Glavo

@Glavo Glavo commented Oct 27, 2026

Copy link
Copy Markdown
Member
  1. 删除 TabControl
  2. 将不需要渲染标签页的功能拆分至 TabController 类
  3. 重构相关代码,优化内存占用与性能

Glavo added 23 commits October 27, 2026 21:28
Assisted-by: codex:gpt-6-astra
Assisted-by: codex:gpt-6-astra

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 TabControl with TabController and lightweight TabItem objects.
  • Simplifies TabHeader layout 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;
}
@Glavo
Glavo merged commit efa1012 into HMCL-dev:main Oct 27, 2026
3 checks passed
@Glavo
Glavo deleted the tab-header branch October 27, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants