Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions nebula_app/src/gpui_shell/workspace/sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ use crate::i18n::Message;
/// 折叠箭头的固定布局槽。图标是 SVG,不应借任一字体的 advance 决定留白。
const TABS_DISCLOSURE_SLOT_W: f32 = 24.0;

/// 标签行的水平内边距。图标列从这里开始,并与上方折叠箭头对齐。
const TAB_ROW_PAD_X: f32 = 8.0;
/// 标签色光条画在行首内边距里,右缘与图标之间留 `TAB_STRIP_GAP`。旧壳
/// 的光条(左内缩 4)配的是 14px 内容起点;照搬到 8px 内边距会让光条
/// 贴住图标,所以位置从内边距反推,不另立一个字面量。
const TAB_STRIP_W: f32 = 2.5;
const TAB_STRIP_GAP: f32 = 4.5;
const TAB_STRIP_LEFT: f32 = TAB_ROW_PAD_X - TAB_STRIP_GAP - TAB_STRIP_W;

/// `SidebarActivity::WaitingInput` / `Attention` 共用的字位:Nerd Font
/// `nf-fa-hand_paper_o`(开掌)。已核对打包字体
/// `assets/fonts/MapleMonoNormal-NF-CN-Regular.ttf` 的 cmap 覆盖这个码位;换字体
Expand Down Expand Up @@ -254,9 +263,8 @@ impl NebulaWorkspace {
row_w * 0.45,
);
let cross_window_drag = self.cross_window_drag_payload(ix, cx);
// 用户明确设置过的标签色:行左侧一条竖光条(旧壳 strip,位置与
// 尺寸同源:左内缩 4、上下各留 7、宽 2.5)。默认标签不占这层
// 视觉层级。
// 用户明确设置过的标签色:行左侧一条竖光条(上下各留 7,与旧壳
// 同源;水平位置见 `TAB_STRIP_LEFT`)。默认标签不占这层视觉层级。
let strip = tab_color.map(|color| gpui::Rgba {
r: color.r as f32 / 255.0,
g: color.g as f32 / 255.0,
Expand Down Expand Up @@ -362,7 +370,7 @@ impl NebulaWorkspace {
// 撑开的行会重新引入上面那个症状。
.overflow_hidden()
.gap_2()
.px_2()
.px(px(TAB_ROW_PAD_X))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

[P2] Preserve the existing rem-based row padding. In pinned GPUI a71e175, px_2() is generated as rems(0.5), not an unconditional 8 logical pixels (gpui_macros/src/styles.rs:948-951). Pinned gpui-component e95f47d sets each window's rem size from cx.theme().font_size in Root::render, and this application's theme.rs:775 uses the configured UI font size with a 14px default. Consequently this replacement moves the icon/title start from 7px to 8px at the default size, and from 12px to 8px at a 24px UI size, while the TABS/header padding still scales. This contradicts the stated unchanged-column scope and breaks alignment for custom font sizes. Keep the existing padding unit and derive the strip geometry from the actual resolved padding, including small-font bounds; check at least the default and an enlarged UI font size. This finding is from the actual style/Root/theme code, not an additional visual run.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, confirmed: px_2() is rems(0.5) and Root sets the rem size from theme.font_size, so the fixed 8px was wrong.

Fixed in 0102365. px_2() is restored and unchanged. The strip now sits at the row's left edge (.left_0()) instead of the legacy 4px inset, so its gap to the content is 0.5rem − 2.5px and scales with the UI font: 2.5 / 4.5 / 9.5px at 10 / 14 / 24px. I checked 14px and 24px in a real window; screenshots are in the updated description.

I also tried keeping a fixed 4.5px gap derived from window.rem_size(). At 24px the strip then floats inside the padding and reads like a glyph in front of the title, so I dropped that approach.

.h(px(row_height))
.items_center()
// 旧壳 pill 圆角 = UI_CORNER_RADIUS_LOGICAL(8),rounded_md(6)
Expand Down Expand Up @@ -416,9 +424,9 @@ impl NebulaWorkspace {
row.child(
div()
.absolute()
.left(px(4.0))
.left(px(TAB_STRIP_LEFT))
.top(px(7.0))
.w(px(2.5))
.w(px(TAB_STRIP_W))
.h(px(row_height - 14.0))
.rounded_full()
.bg(color),
Expand Down
Loading