Replace translucency presets with a real continuous slider

ElyShell now hosts a translucency_slider: Entity<SliderState> bound to
0..=100 step 1, defaulting to DEFAULT_TRANSLUCENCY_PCT. A subscription
on SliderEvent::Change writes the rounded value into the core via
set_translucency_pct, so dragging the thumb mutates the persisted
appearance setting in real time.

The appearance form swaps the static track-and-thumb visual for the
gpui_component Slider (160 wide) plus a live percentage readout. The
three preset chips move below the row as fast-set buttons that go
through a new set_translucency_pct_from_preset helper which writes
both core and the SliderState so the thumb tracks the chip choice.

reset_appearance now resets the slider to DEFAULT_TRANSLUCENCY_PCT
alongside resetting the core, keeping every UI source of truth in
lock-step.
This commit is contained in:
2026-05-09 19:46:43 -04:00
parent 3108f3265b
commit 797560d71c
6 changed files with 89 additions and 39 deletions
+30 -4
View File
@@ -1,9 +1,10 @@
use ely_domain::{
ArchivePolicy, DiagnosticsReportingPolicy, DownloadPolicy, FavoriteLimit,
HistoryRecordingPolicy, NewTabDestination, ProfileId, ProfileSyncPolicy, SearchEngine,
SyncObjectKind, SyncObjectPolicy, ThemeMode, UpdatePolicy, WallpaperTheme,
ArchivePolicy, DEFAULT_TRANSLUCENCY_PCT, DiagnosticsReportingPolicy, DownloadPolicy,
FavoriteLimit, HistoryRecordingPolicy, NewTabDestination, ProfileId, ProfileSyncPolicy,
SearchEngine, SyncObjectKind, SyncObjectPolicy, ThemeMode, UpdatePolicy, WallpaperTheme,
};
use gpui::Context;
use gpui_component::slider::SliderValue;
use super::{ElyShell, ShellState};
@@ -86,11 +87,36 @@ impl ElyShell {
}
}
pub(super) fn reset_appearance(&mut self, cx: &mut Context<Self>) {
pub(crate) fn set_translucency_pct_from_preset(
&mut self,
value: u8,
window: &mut gpui::Window,
cx: &mut Context<Self>,
) {
self.set_translucency_pct(value, cx);
let slider = self.translucency_slider.clone();
slider.update(cx, |state, cx| {
state.set_value(SliderValue::Single(f32::from(value)), window, cx);
});
}
pub(super) fn reset_appearance(
&mut self,
window: &mut gpui::Window,
cx: &mut Context<Self>,
) {
if let ShellState::Ready(core) = &mut self.state {
core.reset_appearance();
cx.notify();
}
let slider = self.translucency_slider.clone();
slider.update(cx, |state, cx| {
state.set_value(
SliderValue::Single(f32::from(DEFAULT_TRANSLUCENCY_PCT)),
window,
cx,
);
});
}
pub(super) fn reset_general_settings(&mut self, cx: &mut Context<Self>) {