From 07369a3aba6ccbac8d4b8ddfc233e22083ad030b Mon Sep 17 00:00:00 2001 From: layue13 Date: Sat, 7 Nov 2026 20:46:46 +0000 Subject: [PATCH] fix(ui): golden-ratio chrome layout hierarchy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apply φ≈1.618 sidebar:content splits and φ spacing ladder for title:body tool-density chrome (LayoutMetrics), keeping tactility. --- .../org/jackhuang/hmcl/ui/LayoutMetrics.java | 52 +++++++++++++++++++ .../ui/decorator/DecoratorAnimatedPage.java | 18 +++++-- .../hmcl/ui/main/DownloadSettingsPage.java | 5 +- .../org/jackhuang/hmcl/ui/main/MainPage.java | 5 +- .../jackhuang/hmcl/ui/main/SettingsPage.java | 6 ++- HMCL/src/main/resources/assets/css/root.css | 44 +++++++++------- 6 files changed, 99 insertions(+), 31 deletions(-) create mode 100644 HMCL/src/main/java/org/jackhuang/hmcl/ui/LayoutMetrics.java diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/LayoutMetrics.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/LayoutMetrics.java new file mode 100644 index 0000000000..3cf6673392 --- /dev/null +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/LayoutMetrics.java @@ -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))); + } +} diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorAnimatedPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorAnimatedPage.java index fd9122768c..07be88820f 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorAnimatedPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/decorator/DecoratorAnimatedPage.java @@ -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); } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/DownloadSettingsPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/DownloadSettingsPage.java index aa1670c39f..b2f90db436 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/DownloadSettingsPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/DownloadSettingsPage.java @@ -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); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java index ffd24a34b4..bdd408ad7b 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java @@ -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)); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/SettingsPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/SettingsPage.java index 1cf761aab1..663b287621 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/SettingsPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/SettingsPage.java @@ -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); diff --git a/HMCL/src/main/resources/assets/css/root.css b/HMCL/src/main/resources/assets/css/root.css index e66b82ddd3..85b14ecca4 100644 --- a/HMCL/src/main/resources/assets/css/root.css +++ b/HMCL/src/main/resources/assets/css/root.css @@ -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; }