diff --git a/crates/signed_app/src/settings/mod.rs b/crates/signed_app/src/settings/mod.rs index a229623..cdf1e69 100644 --- a/crates/signed_app/src/settings/mod.rs +++ b/crates/signed_app/src/settings/mod.rs @@ -60,6 +60,7 @@ impl Render for SettingsDialog { Dialog::new("settings-dialog") .handle(self.handle.clone()) + .width(px(600.)) .height(px(560.)) .title("Settings") .content(move |_, cx| { diff --git a/crates/ui/src/components/dialog.rs b/crates/ui/src/components/dialog.rs index 9488aa7..9f62145 100644 --- a/crates/ui/src/components/dialog.rs +++ b/crates/ui/src/components/dialog.rs @@ -33,8 +33,9 @@ use gpui::{ }; use crate::components::button::{Button, ButtonVariant}; -use crate::components::common::h_flex; -use crate::components::common::{DIALOG_LAYER, Sizable, StyledExt as _, floating_panel, v_flex}; +use crate::components::common::{ + DIALOG_LAYER, Sizable, StyledExt as _, floating_panel, h_flex, v_flex, +}; use crate::components::grain::grain; use crate::components::scroll_area::ScrollArea; use crate::icons::IconRole; @@ -98,6 +99,7 @@ pub struct Dialog { content: Option, actions: Option, min_width: Option, + width: Option, height: Option, style: StyleRefinement, } @@ -122,6 +124,7 @@ impl Dialog { content: None, actions: None, min_width: None, + width: None, height: None, style: StyleRefinement::default(), } @@ -217,6 +220,15 @@ impl Dialog { self } + /// Sets the panel's fixed width, capped at 90% of the window. + pub fn width(mut self, width: W) -> Self + where + W: Into, + { + self.width = Some(width.into()); + self + } + /// Sets the panel's height, body content taller than the panel scrolls. pub fn height(mut self, height: H) -> Self where @@ -255,11 +267,12 @@ impl RenderOnce for Dialog { }) }); - let (scrim_color, foreground, radius, shadows, enter_duration) = { + let (scrim_color, foreground, background, radius, shadows, enter_duration) = { let theme = cx.theme(); ( theme.colors.overlay, theme.colors.foreground, + theme.colors.background, theme.radius.overlay, theme.elevations.dialog.shadows(), theme.motion.overlay, @@ -303,15 +316,19 @@ impl RenderOnce for Dialog { .track_focus(&focus) .role(role) .aria_label(label) - .when_some(self.min_width, |panel, width| panel.min_w(width)) - .when(self.min_width.is_none(), |panel| { + .when_some(self.width, |panel, width| panel.w(width)) + .when(self.width.is_none() && self.min_width.is_none(), |panel| { panel.min_w(DIALOG_MIN_WIDTH) }) + .when_some(self.min_width, |panel, width| panel.min_w(width)) .max_w(relative(0.9)) .when_some(height, |panel, height| panel.h(height)) .text_color(foreground), shadows, ) + // The panel behind the dialog is `background` (pure white/black), so + // the dialog matches it instead of the muted `surface` tint. + .bg(background) .overflow_hidden() .on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation()) .on_key_down({