Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Precomputed wallpaper at the workspace sidebar

## Status

Accepted for dark workspace themes with the wallpaper extended into the chrome.

## Context

The selected L4-B prototype gives the left rail a softer image while preserving
the image detail to its right. The wallpaper slider also needs to preview the
image beneath the Settings surface and reach the full image in the terminal.

## Evidence

The approved prototype blends a 5.5 px kernel and a 2.6 px kernel into the sharp
image across a 64 px feather beyond the sidebar. Its strongest band reduces
contrast by 24 percent, then applies a theme tint and fine black-and-white grain.

## Decision

Sample the already decoded wallpaper into a window-local strip after fitting
and alignment. The file loader and strip baker share a serial preparation slot.
Each window retains one strip and limits it to 2 MiB of pixels. A short delay
coalesces geometry changes, and generation checks cancel outdated work and
prevent stale results from reaching the window.

The existing 38 percent default and the Settings background retain their
composition. Above that default, a second draw of the fitted wallpaper reveals
the image over the terminal surface so the slider can reach the original at
100 percent. Holding the wallpaper slider temporarily fades the Settings chrome
and previews the same extended image contribution. Slider movements only change
opacity and use the cached texture.

## Rejected alternatives

- Filtering each frame would repeat the same work during scrolling and dragging.
- Retaining full-window variants would duplicate unaffected pixels in every window.
- Blurring the source before fitting would make the apparent kernel size depend
on image dimensions and the selected fit mode.

## Consequences

A changed source, fit, theme tint or settled viewport needs a new strip. The
sharp wallpaper is available while the strip is prepared. The CPU path and the
finished texture use the same BGRA and premultiplied filtering rules for
transparent edges as the existing wallpaper loader.

## Validation

The isolated loader and optics suite passed nine tests. On Linux ARM64, a
24-sample synthetic fixture measured 57–139 ms median preparation time with
0.81–2.00 MiB of retained strip pixels across 720p, 1080p and 2160p viewports.
The timing excludes image decode, the coalescing delay and texture upload.

## Supersedes

None. Settings continues to use its existing background treatment.

## Revisit when

More than one live animated source or an additional fitted effect needs to share
the preparation budget.
2 changes: 1 addition & 1 deletion pebrel_app/src/display/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5647,7 +5647,7 @@ impl Display {
self.nebula_window_opacity = 1.0;
self.nebula_background = None;
self.nebula_background_image = None;
self.nebula_background_image_opacity = 0.38;
self.nebula_background_image_opacity = nebula_settings::DEFAULT_BACKGROUND_IMAGE_OPACITY;
self.nebula_background_image_fit = BackgroundImageFit::default();
self.nebula_background_image_alignment = BackgroundImageAlignment::default();
self.nebula_background_image_cover_chrome = false;
Expand Down
2 changes: 1 addition & 1 deletion pebrel_app/src/display/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ pub(super) fn nebula_settings_load(config: &UiConfig) -> NebulaRuntimeSettings {
opacity: config.window_opacity(),
background: None,
background_image: None,
background_image_opacity: 0.38,
background_image_opacity: nebula_settings::DEFAULT_BACKGROUND_IMAGE_OPACITY,
background_image_fit: BackgroundImageFit::default(),
background_image_alignment: BackgroundImageAlignment::default(),
background_image_cover_chrome: false,
Expand Down
3 changes: 3 additions & 0 deletions pebrel_app/src/gpui_shell/file_editor/chrome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ impl TextFileView {
.flex_shrink_0()
.icon(Icon::new(IconName::PanelRight).size(px(design::ICON_SIZE)))
.selected(self.show_details)
.when(self.show_details, |button| {
crate::gpui_shell::theme::selected_glass(button, cx)
})
.tooltip(language.text(Message::EditorDetailsToggle))
.on_click(cx.listener(|this, _, _, cx| {
if this.details_hosted {
Expand Down
105 changes: 92 additions & 13 deletions pebrel_app/src/gpui_shell/settings_pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use gpui::prelude::FluentBuilder as _;
use gpui::{
App, AppContext as _, Context, Entity, EventEmitter, FocusHandle, Focusable, Hsla,
InteractiveElement as _, IntoElement, KeyDownEvent, ModifiersChangedEvent, MouseButton,
MouseMoveEvent, ParentElement as _, Render, RenderImage, Rgba as GpuiRgba, SharedString,
StatefulInteractiveElement as _, Styled as _, Subscription, Task, Window, anchored, deferred,
div, img, px,
MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement as _, Render, RenderImage,
Rgba as GpuiRgba, SharedString, StatefulInteractiveElement as _, Styled as _, Subscription,
Task, Window, anchored, deferred, div, img, px,
};
use gpui_component::input::InputEvent;
use gpui_component::select::{SelectEvent, SelectItem};
Expand Down Expand Up @@ -87,6 +87,7 @@ mod theme_transfer;
mod theme_transfer_view;

use localization::*;
pub(super) use navigation::SETTINGS_NAV_WIDTH;
use navigation::*;
use shell_picker::*;
pub(super) use status::SshStatus;
Expand All @@ -100,6 +101,7 @@ pub enum SettingsPaneEvent {
Close,
Changed,
BackupRestored,
WallpaperPreview,
/// 导入 Profile 已落盘;Tab 的 Shell 面板若正打开,需要重建候选快照。
TerminalProfilesChanged,
/// 设置页"连接"按钮:宿主开 SSH tab(连接语义在业务层)。
Expand Down Expand Up @@ -170,6 +172,10 @@ pub struct SettingsPane {
pub(super) theme_foreground_picker: theme_foreground::ThemeForegroundState,
opacity_slider: Entity<SliderState>,
wallpaper_opacity_slider: Entity<SliderState>,
wallpaper_peek: bool,
wallpaper_peek_changed: bool,
appearance_expanded: bool,
appearance_section: Option<AppearanceSection>,
scroll_speed_slider: Entity<SliderState>,
scroll_speed_focus: FocusHandle,
pub(super) proxy_url_input: Entity<InputState>,
Expand Down Expand Up @@ -548,13 +554,38 @@ impl SettingsPane {
return;
}
self.runtime.background_image_opacity = opacity;
super::wallpaper::set_image_opacity_live(opacity, cx);
cx.notify();
if self.wallpaper_peek {
self.wallpaper_peek_changed = true;
} else {
self.persist_wallpaper_opacity(cx);
}
}

fn persist_wallpaper_opacity(&mut self, cx: &mut Context<Self>) {
let opacity = self.runtime.background_image_opacity;
self.schedule_slider_persist(
vec![("background_image_opacity", format!("{opacity:.2}"))],
cx,
);
}

pub(super) fn wallpaper_peeking(&self) -> bool {
self.wallpaper_peek && self.active_section == 1
}

pub(super) fn set_wallpaper_peek(&mut self, active: bool, cx: &mut Context<Self>) {
if self.wallpaper_peek != active {
self.wallpaper_peek = active;
if !active && std::mem::take(&mut self.wallpaper_peek_changed) {
self.persist_wallpaper_opacity(cx);
}
cx.emit(SettingsPaneEvent::WallpaperPreview);
cx.notify();
}
}

/// `Change` 同时覆盖鼠标拖动和键盘调整,因此统一用 debounce 延后落盘:
/// 每个新事件覆盖上一个待落盘任务,旧 `Task` drop 即取消。
///
Expand Down Expand Up @@ -1048,7 +1079,26 @@ impl SettingsPane {
.w(px(220.0))
.items_center()
.gap_3()
.child(div().flex_1().min_w_0().child(Slider::new(state)))
.child(
div()
.flex_1()
.min_w_0()
.when(
state == &self.wallpaper_opacity_slider && cx.theme().is_dark(),
|slider| {
slider.capture_any_mouse_down(cx.listener(
|this, event: &MouseDownEvent, _, cx| {
if event.button == MouseButton::Left
&& super::wallpaper::wallpaper_available_for_preview(cx)
{
this.set_wallpaper_peek(true, cx);
}
},
))
},
)
.child(Slider::new(state)),
)
.child(div()
.w(px(48.0))
.flex_shrink_0()
Expand Down Expand Up @@ -1565,8 +1615,10 @@ impl SettingsPane {
let foreground = theme.foreground;
let hover_bg = crate::gpui_shell::theme::settings_hover_bg(cx, false);
let hairline = crate::gpui_shell::theme::settings_hairline(cx);
let glass = crate::gpui_shell::theme::selection_glass(cx);
// 返回入口和分类共用紧凑菜单尺寸;字号与搜索框一致,不继承终端配置字号。
let mut nav = v_flex()
let nav = v_flex()
.debug_selector(|| "settings-sidebar".to_owned())
.w(px(SETTINGS_NAV_WIDTH))
.h_full()
.flex_shrink_0()
Expand All @@ -1576,8 +1628,8 @@ impl SettingsPane {
.gap(px(2.0))
.text_sm()
.line_height(px(20.0))
.border_r_1()
.border_color(hairline)
.opacity(if self.wallpaper_peeking() { 0.16 } else { 1.0 })
.when(!theme.is_dark(), |nav| nav.border_r_1().border_color(hairline))
.child(
div()
.id("settings-back")
Expand All @@ -1598,15 +1650,20 @@ impl SettingsPane {
)
.child(self.render_nav_search(window, cx));
let searching = !self.settings_search_input.read(cx).value().trim().is_empty();
let mut items = v_flex().w_full().gap(px(2.0));
let mut previous_group = None;
for ix in self.matching_settings_sections(cx) {
let group = NAV_GROUPS.iter().position(|(_, sections)| sections.contains(&ix));
if !searching && previous_group.is_some() && previous_group != group {
nav = nav.child(div().h(px(10.0)).flex_shrink_0());
items = items.child(div().h(px(10.0)).flex_shrink_0());
}
previous_group = group;
if ix == 1 && !searching {
items = items.child(self.appearance_navigation(glass, cx));
continue;
}
let active = ix == self.active_section;
nav = nav.child(
items = items.child(
div()
.id(("settings-nav", ix))
.debug_selector(move || format!("settings-nav-{ix}"))
Expand All @@ -1619,9 +1676,18 @@ impl SettingsPane {
.gap(px(10.0))
.rounded_md()
.cursor_pointer()
// 底色和墨色表达选中,避免中文导航因字重匹配而突然变粗。
.font_weight(gpui::FontWeight::NORMAL)
.when(active, |item| item.bg(active_bg).text_color(active_fg))
// 选中态同时改变底色、墨色和字重,余光扫过也能确认当前位置。
.font_weight(if active {
gpui::FontWeight::MEDIUM
} else {
gpui::FontWeight::NORMAL
})
.when_some(glass, |item, glass| {
if active { glass.apply(item) } else { glass.reserve(item) }
})
.when(active, |item| {
item.text_color(active_fg).when(glass.is_none(), |item| item.bg(active_bg))
})
.when(!active, |item| item.text_color(muted).hover(|s| s.bg(hover_bg)))
.on_click(cx.listener(move |this, _, _, cx| {
this.active_section = ix;
Expand All @@ -1638,7 +1704,7 @@ impl SettingsPane {
.child(section_label(ix, language)),
);
}
nav.child(div().flex_1().min_h(px(24.0)))
nav.child(div().flex_1().min_h_0().overflow_y_scrollbar().child(items))
.child(
Button::new("settings-restore-defaults")
.icon(IconName::Undo2)
Expand Down Expand Up @@ -1687,11 +1753,22 @@ impl Render for SettingsPane {
let mobile_page = self.active_section == MOBILE_SECTION;
let form_page = matches!(self.active_section, 1 | 2 | 5 | 6 | 8);
let has_cards = form_page || mobile_page || self.active_section == 9;
let peeking = self.wallpaper_peeking();

div()
.size_full()
.font(crate::gpui_shell::typography::ui_font(cx))
.track_focus(&self.focus_handle)
.when(peeking, |root| {
root.capture_any_mouse_up(cx.listener(|this, event: &MouseUpEvent, _, cx| {
if event.button == MouseButton::Left {
this.set_wallpaper_peek(false, cx);
}
}))
.on_mouse_up_out(MouseButton::Left, cx.listener(|this, _, _, cx| {
this.set_wallpaper_peek(false, cx);
}))
})
// 旧壳 `input/chrome.rs` 的合同是页面任何左键先撤销捕获。
// 行自身会 stop_propagation 并完成「同行取消 / 他行转移」;其它
// 控件的 mouse_down 仍先取得自己的焦点,这里只清状态,不抢焦点,
Expand Down Expand Up @@ -1736,7 +1813,9 @@ impl Render for SettingsPane {
.flex_1()
.min_w_0()
.h_full()
.debug_selector(|| "settings-content".to_owned())
.when(has_cards, |pane| pane.bg(crate::gpui_shell::theme::settings_canvas_tint(cx)))
.opacity(if peeking { 0.16 } else { 1.0 })
.child(
v_flex()
.flex_1()
Expand Down
7 changes: 4 additions & 3 deletions pebrel_app/src/gpui_shell/settings_pane/about.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ impl SettingsPane {
let warning = theme.warning;
let danger = theme.danger;
let base_px = self.font_size_px(cx);
let dark = theme.is_dark();
let cached_update = crate::update_download::cached_asset().filter(|asset| {
!managed
&& (crate::update_check::is_newer(&asset.version, env!("CARGO_PKG_VERSION"))
Expand Down Expand Up @@ -245,7 +246,7 @@ impl SettingsPane {
.text_color(muted)
.child(title)
};
let update_column = v_flex()
let update_column = crate::gpui_shell::theme::settings_card(v_flex(), cx)
.flex_1()
.min_w(px(280.0))
.child(section_title(
Expand Down Expand Up @@ -280,7 +281,7 @@ impl SettingsPane {
.when_some(distribution.message(), |column, message| {
column.child(div().text_color(muted).child(language.text(message)))
});
let actions = v_flex()
let actions = crate::gpui_shell::theme::settings_card(v_flex(), cx)
.flex_1()
.min_w(px(280.0))
.child(section_title(
Expand Down Expand Up @@ -320,7 +321,7 @@ impl SettingsPane {
.w_full()
.flex_wrap()
.items_start()
.gap(px(64.0))
.gap(px(if dark { 16.0 } else { 64.0 }))
.child(update_column)
.child(actions),
)
Expand Down
8 changes: 7 additions & 1 deletion pebrel_app/src/gpui_shell/settings_pane/appearance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,13 @@ impl SettingsPane {
),
);
let settings = self.appearance_advanced_settings(window, cx);
v_flex().w_full().gap(px(GROUP_GAP)).child(selectors).child(settings)
v_flex()
.w_full()
.gap(px(GROUP_GAP))
.children(
self.show_appearance_section(AppearanceSection::Theme, cx).then_some(selectors),
)
.child(settings)
}
}

Expand Down
15 changes: 11 additions & 4 deletions pebrel_app/src/gpui_shell/settings_pane/appearance_advanced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,17 @@ impl SettingsPane {
v_flex()
.w_full()
.gap(px(GROUP_GAP))
.child(terminal)
.child(cursor)
.child(interface)
.child(custom_background)
.children(
self.show_appearance_section(AppearanceSection::Terminal, cx).then_some(terminal),
)
.children(self.show_appearance_section(AppearanceSection::Cursor, cx).then_some(cursor))
.children(
self.show_appearance_section(AppearanceSection::Interface, cx).then_some(interface),
)
.children(
self.show_appearance_section(AppearanceSection::Background, cx)
.then_some(custom_background),
)
}

pub(super) fn custom_effect_settings(
Expand Down
Loading
Loading