fix(ui): golden-ratio chrome layout hierarchy
Mirror Repository / Mirror to CNB (push) Skipped
Mirror Repository / Mirror to Gitee (push) Skipped
Check Codes / build (push) Failing after 2m45s
Check Codes / build (pull_request) Successful in 3m5s
Java CI / build (push) Failing after 3h0m1s
Java CI / build (pull_request) Failing after 3h0m1s

Apply φ≈1.618 sidebar:content splits and φ spacing ladder for
title:body tool-density chrome (LayoutMetrics), keeping tactility.
This commit is contained in:
layue13 committed 2026-11-07 20:46:46 +00:00
1 parent e69464105a
commit 07369a3aba
6 files changed
+99 -31

No files matched your search

@@ -0,0 +1,52 @@
// SPDX-FileCopyrightText: Copyright (C) 2020 The HMCL Authors
// SPDX-License-Identifier: GPL-3.0-or-later WITH AdditionRef-HMCL
package org.jackhuang.hmcl.ui;
/// Golden-ratio layout metrics for Anthropic tool-mode chrome.
///
/// Primary splits use φ ≈ 1.618 (sidebar:content = 1:φ). Spacing uses the φ ladder
/// from an 8px base so hierarchy stays dense — not landing-page whitespace.
public final class LayoutMetrics {
/// Golden ratio.
public static final double PHI = 1.618033988749895;
/// Sidebar share of a page: 1 / (1 + φ) ≈ 0.382 so sidebar:content = 1:φ.
public static final double SIDEBAR_FRACTION = 1.0 / (1.0 + PHI);
/// Design-minimum page width used when the node has not been laid out yet.
public static final double DESIGN_PAGE_WIDTH = 800.0;
/// Tool-density clamp: keep the rail usable without eating the content column.
public static final double SIDEBAR_MIN = 220.0;
/// φ share of [#DESIGN_PAGE_WIDTH] — exact 1:φ at the launcher minimum width.
public static final double SIDEBAR_MAX = Math.rint(DESIGN_PAGE_WIDTH * SIDEBAR_FRACTION); // 306
/// φ spacing ladder from an 8px base (…, 5, 8, 13, 21, 34).
public static final double SPACE_XS = 5.0;
public static final double SPACE_SM = 8.0;
public static final double SPACE_MD = 13.0;
public static final double SPACE_LG = 21.0;
public static final double SPACE_XL = 34.0;
/// Title-bar / touch target height (a11y floor from the skill).
public static final double TITLE_BAR = 44.0;
/// Primary CTA height on the home page (Fibonacci neighbour of title bar / φ body).
public static final double LAUNCH_HEIGHT = 55.0;
/// Primary CTA width (Fibonacci; pairs with the φ sidebar rail).
public static final double LAUNCH_WIDTH = 233.0;
private LayoutMetrics() {
}
/// Resolves the fixed sidebar width for a page of the given width.
///
/// @param pageWidth the animated page width in pixels; values ≤ 1 fall back to the design minimum
/// @return a width clamped to [{@link #SIDEBAR_MIN}, {@link #SIDEBAR_MAX}] on the 1:φ fraction
public static double sidebarWidth(double pageWidth) {
double width = pageWidth > 1.0 ? pageWidth : DESIGN_PAGE_WIDTH;
return Math.rint(Math.max(SIDEBAR_MIN, Math.min(SIDEBAR_MAX, width * SIDEBAR_FRACTION)));
}
}
@@ -2,16 +2,19 @@
// SPDX-License-Identifier: GPL-3.0-or-later WITH AdditionRef-HMCL
package org.jackhuang.hmcl.ui.decorator;
import javafx.beans.binding.Bindings;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import org.jackhuang.hmcl.ui.FXUtils;
import org.jackhuang.hmcl.ui.LayoutMetrics;
import org.jackhuang.hmcl.ui.construct.AdvancedListBox;
import org.jetbrains.annotations.NotNullByDefault;
import org.jetbrains.annotations.Nullable;
/// Lays out a fixed-width sidebar and a growing content area as independent animation targets.
/// Lays out a φ-proportioned sidebar and a growing content area as independent animation targets.
///
/// Sidebar:content ≈ 1:φ (see [LayoutMetrics]), clamped for tool-mode density.
@NotNullByDefault
public class DecoratorAnimatedPage extends BorderPane {
@@ -25,7 +28,12 @@ public class DecoratorAnimatedPage extends BorderPane {
/// Creates both animation targets without requiring CSS or skin initialization.
public DecoratorAnimatedPage() {
getStyleClass().add("gray-background");
FXUtils.setLimitWidth(left, 200);
var sidebarWidth = Bindings.createDoubleBinding(
() -> LayoutMetrics.sidebarWidth(getWidth()),
widthProperty());
left.minWidthProperty().bind(sidebarWidth);
left.prefWidthProperty().bind(sidebarWidth);
left.maxWidthProperty().bind(sidebarWidth);
sidebar.setMinSize(0, 0);
left.setCenter(sidebar);
setLeft(left);
@@ -42,11 +50,11 @@ public class DecoratorAnimatedPage extends BorderPane {
return left.getBottom();
}
/// Replaces the bottom content, reserving its preferred height and a 12-pixel bottom gap.
/// Replaces the bottom content, reserving its preferred height and a φ-md bottom gap.
/// Passing null removes it without replacing the sidebar animation target.
public void setSidebarBottom(@Nullable Node node) {
if (node != null) {
BorderPane.setMargin(node, new Insets(0, 0, 12, 0));
BorderPane.setMargin(node, new Insets(0, 0, LayoutMetrics.SPACE_MD, 0));
}
left.setBottom(node);
}
@@ -15,6 +15,7 @@ import javafx.scene.layout.*;
import org.jackhuang.hmcl.setting.ProxyType;
import org.jackhuang.hmcl.task.FetchTask;
import org.jackhuang.hmcl.ui.FXUtils;
import org.jackhuang.hmcl.ui.LayoutMetrics;
import org.jackhuang.hmcl.ui.WeakListenerHolder;
import org.jackhuang.hmcl.ui.construct.*;
import org.jackhuang.hmcl.util.Holder;
@@ -30,8 +31,8 @@ public class DownloadSettingsPage extends StackPane {
private final WeakListenerHolder holder = new WeakListenerHolder();
public DownloadSettingsPage() {
VBox content = new VBox(10);
content.setPadding(new Insets(10, 12, 12, 12));
VBox content = new VBox(LayoutMetrics.SPACE_MD);
content.setPadding(new Insets(LayoutMetrics.SPACE_SM, LayoutMetrics.SPACE_MD, LayoutMetrics.SPACE_MD, LayoutMetrics.SPACE_MD));
content.setFillWidth(true);
ScrollPane scrollPane = new ScrollPane(content);
FXUtils.smoothScrolling(scrollPane);
@@ -27,6 +27,7 @@ import org.jackhuang.hmcl.setting.GameDirectoryManager;
import org.jackhuang.hmcl.theme.Themes;
import org.jackhuang.hmcl.ui.Controllers;
import org.jackhuang.hmcl.ui.FXUtils;
import org.jackhuang.hmcl.ui.LayoutMetrics;
import org.jackhuang.hmcl.ui.SVG;
import org.jackhuang.hmcl.ui.animation.AnimationUtils;
import org.jackhuang.hmcl.ui.decorator.DecoratorPage;
@@ -79,8 +80,8 @@ public final class MainPage extends StackPane implements DecoratorPage {
state.setValue(new State(null, titleNode, false, false, true));
// Tool-density mode (skill): compressed chrome padding, not landing-page whitespace.
setPadding(new Insets(12, 14, 14, 14));
// Tool-density φ ladder (skill): md/lg insets — not landing-page whitespace.
setPadding(new Insets(LayoutMetrics.SPACE_MD, LayoutMetrics.SPACE_MD, LayoutMetrics.SPACE_LG, LayoutMetrics.SPACE_MD));
@@ -14,6 +14,7 @@ import org.jackhuang.hmcl.Metadata;
import org.jackhuang.hmcl.task.Schedulers;
import org.jackhuang.hmcl.ui.Controllers;
import org.jackhuang.hmcl.ui.FXUtils;
import org.jackhuang.hmcl.ui.LayoutMetrics;
import org.jackhuang.hmcl.ui.construct.*;
import org.jackhuang.hmcl.ui.construct.MessageDialogPane.MessageType;
import org.jackhuang.hmcl.util.Lang;
@@ -47,8 +48,9 @@ public final class SettingsPage extends ScrollPane {
public SettingsPage() {
this.setFitToWidth(true);
VBox rootPane = new VBox(8);
rootPane.setPadding(new Insets(10, 12, 12, 12));
// Title:body φ ladder — tight tool density (sm gap, md/lg insets).
VBox rootPane = new VBox(LayoutMetrics.SPACE_SM);
rootPane.setPadding(new Insets(LayoutMetrics.SPACE_SM, LayoutMetrics.SPACE_MD, LayoutMetrics.SPACE_MD, LayoutMetrics.SPACE_MD));
this.setContent(rootPane);
FXUtils.smoothScrolling(this);
+24 -20
View File
@@ -242,8 +242,9 @@
}
.class-title {
/* Title block of title:body ≈ 1:φ — md/sm padding under tool density */
-fx-font-size: 11px;
-fx-padding: 14 16 10 16;
-fx-padding: 13 13 8 13;
}
.class-title Text {
@@ -258,7 +259,7 @@
}
.advanced-list-box-content {
-fx-padding: 12 0 0 0;
-fx-padding: 13 0 0 0;
-fx-spacing: 0;
}
@@ -271,8 +272,9 @@
}
.iconed-item .iconed-item-container {
-fx-padding: 10 16 10 16;
-fx-spacing: 10;
/* Body row under φ title:body — sm/md denser than landing */
-fx-padding: 8 13 8 13;
-fx-spacing: 13;
-fx-font-size: 14;
-fx-alignment: CENTER_LEFT;
}
@@ -287,14 +289,14 @@
}
.iconed-menu-item .iconed-item-container {
-fx-padding: 8 16 8 16;
-fx-spacing: 10;
-fx-padding: 8 13 8 13;
-fx-spacing: 13;
-fx-font-size: 12;
-fx-alignment: CENTER_LEFT;
}
.menu-container {
-fx-padding: 8 16 8 16;
-fx-padding: 8 13 8 13;
}
.popup-menu .scroll-bar .thumb {
@@ -434,16 +436,17 @@
******************************************************************************/
.launch-pane {
-fx-max-height: 64px;
-fx-min-height: 64px;
-fx-max-width: 248px;
-fx-min-width: 248px;
/* φ/Fibonacci CTA: 55×233 pairs with title bar 44 and sidebar rail */
-fx-max-height: 55px;
-fx-min-height: 55px;
-fx-max-width: 233px;
-fx-min-width: 233px;
}
.launch-pane > .jfx-button {
-fx-translate-y: 1px;
-fx-max-height: 62px;
-fx-min-height: 62px;
-fx-max-height: 53px;
-fx-min-height: 53px;
-fx-background-color: -monet-primary;
-fx-opacity: 1; /* Override the opacity of disabled button */
-fx-cursor: hand;
@@ -470,8 +473,8 @@
}
.launch-pane > .jfx-button.launch-button {
-fx-max-width: 214px;
-fx-min-width: 214px;
-fx-max-width: 201px;
-fx-min-width: 201px;
-fx-border-width: 0 1px 0 0;
-fx-border-color: linear-gradient(
to bottom,
@@ -1219,7 +1222,7 @@
.card {
-fx-background-color: -monet-surface-container-low-transparent-80;
-fx-background-radius: 8;
-fx-padding: 12px;
-fx-padding: 13px;
-fx-effect: dropshadow(gaussian, -anthropic-shadow, 6, 0.06, 0, 1);
}
@@ -1234,14 +1237,14 @@
.card-non-transparent {
-fx-background-color: -monet-surface-container-low;
-fx-background-radius: 8;
-fx-padding: 12px;
-fx-padding: 13px;
-fx-effect: dropshadow(gaussian, -anthropic-shadow, 4, 0.04, 0, 1);
}
.card-list {
-fx-padding: 10;
-fx-spacing: 10;
-fx-padding: 13;
-fx-spacing: 13;
}
.md-list-cell {
@@ -1277,7 +1280,8 @@
-fx-background-color: -monet-surface;
-fx-border-color: -monet-outline-variant;
-fx-border-width: 1 0 0 0;
-fx-padding: 10 16 10 16;
/* Body of title:body — sm vertical / md horizontal */
-fx-padding: 8 13 8 13;
-fx-font-size: 12;
}