BlueGit

ict rusty-teams

fix(ui): popups get Fluent shadows and a lighter level when nested

- New elevation tokens (vendor gpui-component elevation.rs): Fluent dark shadow8/16/28/64 (ambient 0.24, key 0.28, blur halved for GPUI), flyout levels, dialog, toast
- Flyout level follows open modal layers per window: framework dialog layer and AppShell dialogs report their count, so a dropdown inside a dialog gets the lighter fill and hover
- popover_style (menus, popovers, selects, combobox, date picker), tooltips, notifications and the framework dialog read the tokens
- Hand-rolled flyouts and dialogs use theme::ElevatedSurface; skin tone picker is a nested flyout; call dialogs and mini call use the shared shadows

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-10-17 · 6 weeks ago

Hash
356ccac406de7ee1663af65f5cb153001eee3f6d
Parent
7cb4a767
41 files changed +369 −157
crates/app-base/src/theme.rs +86 −1
@@ -1,5 +1,6 @@
1 1 use std::borrow::Cow;
2 2
3 use gpui_kit::component::elevation::{self, Elevation, ElevationTokens};
3 4 use gpui_kit::component::{Theme, ThemeMode};
4 5 use gpui_kit::*;
5 6
@@ -19,6 +20,8 @@ const SURFACE_RAISED: u32 = 0x232325;
19 20 const ROW_HOVER: u32 = 0x1c1c1e;
20 21 const POPUP: u32 = 0x2c2c2f;
21 22 const POPUP_HOVER: u32 = 0x38383c;
23 const POPUP_NESTED: u32 = 0x3a3a3e;
24 const POPUP_NESTED_HOVER: u32 = 0x47474c;
22 25 const REPLY_SURFACE: u32 = 0x19191b;
23 26 const BORDER: u32 = 0x262628;
24 27 const BORDER_STRONG: u32 = 0x3f3f42;
@@ -141,8 +144,69 @@ pub fn apply(cx: &mut App) {
141 144 colors.list_hover = color(ROW_HOVER);
142 145 colors.list_active = color(SURFACE_RAISED);
143 146 });
147 cx.set_global(elevation_tokens());
148 }
149
150 fn elevation_tokens() -> ElevationTokens {
151 let flyout = Elevation {
152 fill: color(POPUP),
153 hover: color(POPUP_HOVER),
154 shadow: elevation::shadow16(),
155 };
156 let nested_flyout = Elevation {
157 fill: color(POPUP_NESTED),
158 hover: color(POPUP_NESTED_HOVER),
159 shadow: elevation::shadow16(),
160 };
161 ElevationTokens {
162 flyouts: vec![flyout.clone(), nested_flyout],
163 dialog: Elevation {
164 shadow: elevation::shadow64(),
165 ..flyout.clone()
166 },
167 toast: Elevation {
168 shadow: elevation::shadow8(),
169 ..flyout
170 },
171 }
172 }
173
174 pub fn flyout_shadow() -> Vec<BoxShadow> {
175 elevation::shadow16()
176 }
177
178 pub fn dialog_shadow() -> Vec<BoxShadow> {
179 elevation::shadow64()
180 }
181
182 pub fn toast_shadow() -> Vec<BoxShadow> {
183 elevation::shadow8()
144 184 }
145 185
186 pub fn popup_nested() -> Hsla {
187 color(POPUP_NESTED)
188 }
189
190 pub trait ElevatedSurface: Styled + Sized {
191 fn flyout_surface(self) -> Self {
192 self.bg(popup()).shadow(flyout_shadow())
193 }
194
195 fn nested_flyout_surface(self) -> Self {
196 self.bg(popup_nested()).shadow(flyout_shadow())
197 }
198
199 fn dialog_surface(self) -> Self {
200 self.bg(popup()).shadow(dialog_shadow())
201 }
202
203 fn toast_surface(self) -> Self {
204 self.bg(popup()).shadow(toast_shadow())
205 }
206 }
207
208 impl<T: Styled + Sized> ElevatedSurface for T {}
209
146 210 pub fn font_family() -> SharedString {
147 211 FONT_FAMILY.into()
148 212 }
@@ -341,11 +405,32 @@ pub fn avatar_palette_len() -> usize {
341 405
342 406 #[cfg(test)]
343 407 mod tests {
344 use super::{avatar_color, avatar_palette_len};
408 use super::{POPUP, POPUP_HOVER, POPUP_NESTED, avatar_color, avatar_palette_len, color, elevation_tokens};
345 409
346 410 #[test]
347 411 fn avatar_colors_wrap_around_the_palette() {
348 412 assert_eq!(avatar_color(0), avatar_color(avatar_palette_len()));
349 413 assert_ne!(avatar_color(0), avatar_color(1));
350 414 }
415
416 #[test]
417 fn flyout_over_a_dialog_takes_a_lighter_fill_than_the_dialog() {
418 let tokens = elevation_tokens();
419 assert_eq!(tokens.dialog.fill, color(POPUP));
420 assert_eq!(tokens.flyout_at(0).fill, color(POPUP));
421 let nested = tokens.flyout_at(1);
422 assert_eq!(nested.fill, color(POPUP_NESTED));
423 assert!(nested.fill.l > tokens.dialog.fill.l);
424 assert!(nested.hover.l > nested.fill.l);
425 assert_ne!(nested.fill, color(POPUP_HOVER));
426 }
427
428 #[test]
429 fn fluent_shadow_blur_is_halved_for_gpui() {
430 let shadow = super::flyout_shadow();
431 assert_eq!(shadow[0].blur_radius, gpui_kit::px(1.));
432 assert_eq!(shadow[1].offset.y, gpui_kit::px(8.));
433 assert_eq!(shadow[1].blur_radius, gpui_kit::px(8.));
434 assert_eq!(super::dialog_shadow()[1].blur_radius, gpui_kit::px(32.));
435 }
351 436 }
@@ -1,5 +1,6 @@
1use std::borrow::Cow;
1use std::borrow::Cow;
2
2
3use gpui_kit::component::elevation::{self, Elevation, ElevationTokens};
3use gpui_kit::component::{Theme, ThemeMode};
4use gpui_kit::component::{Theme, ThemeMode};
4use gpui_kit::*;
5use gpui_kit::*;
5
6
@@ -19,6 +20,8 @@ const SURFACE_RAISED: u32 = 0x232325;
19const ROW_HOVER: u32 = 0x1c1c1e;
20const ROW_HOVER: u32 = 0x1c1c1e;
20const POPUP: u32 = 0x2c2c2f;
21const POPUP: u32 = 0x2c2c2f;
21const POPUP_HOVER: u32 = 0x38383c;
22const POPUP_HOVER: u32 = 0x38383c;
23const POPUP_NESTED: u32 = 0x3a3a3e;
24const POPUP_NESTED_HOVER: u32 = 0x47474c;
22const REPLY_SURFACE: u32 = 0x19191b;
25const REPLY_SURFACE: u32 = 0x19191b;
23const BORDER: u32 = 0x262628;
26const BORDER: u32 = 0x262628;
24const BORDER_STRONG: u32 = 0x3f3f42;
27const BORDER_STRONG: u32 = 0x3f3f42;
@@ -141,8 +144,69 @@ pub fn apply(cx: &mut App) {
141 colors.list_hover = color(ROW_HOVER);
144 colors.list_hover = color(ROW_HOVER);
142 colors.list_active = color(SURFACE_RAISED);
145 colors.list_active = color(SURFACE_RAISED);
143 });
146 });
147 cx.set_global(elevation_tokens());
148}
149
150fn elevation_tokens() -> ElevationTokens {
151 let flyout = Elevation {
152 fill: color(POPUP),
153 hover: color(POPUP_HOVER),
154 shadow: elevation::shadow16(),
155 };
156 let nested_flyout = Elevation {
157 fill: color(POPUP_NESTED),
158 hover: color(POPUP_NESTED_HOVER),
159 shadow: elevation::shadow16(),
160 };
161 ElevationTokens {
162 flyouts: vec![flyout.clone(), nested_flyout],
163 dialog: Elevation {
164 shadow: elevation::shadow64(),
165 ..flyout.clone()
166 },
167 toast: Elevation {
168 shadow: elevation::shadow8(),
169 ..flyout
170 },
171 }
172}
173
174pub fn flyout_shadow() -> Vec<BoxShadow> {
175 elevation::shadow16()
176}
177
178pub fn dialog_shadow() -> Vec<BoxShadow> {
179 elevation::shadow64()
180}
181
182pub fn toast_shadow() -> Vec<BoxShadow> {
183 elevation::shadow8()
144}
184}
145
185
186pub fn popup_nested() -> Hsla {
187 color(POPUP_NESTED)
188}
189
190pub trait ElevatedSurface: Styled + Sized {
191 fn flyout_surface(self) -> Self {
192 self.bg(popup()).shadow(flyout_shadow())
193 }
194
195 fn nested_flyout_surface(self) -> Self {
196 self.bg(popup_nested()).shadow(flyout_shadow())
197 }
198
199 fn dialog_surface(self) -> Self {
200 self.bg(popup()).shadow(dialog_shadow())
201 }
202
203 fn toast_surface(self) -> Self {
204 self.bg(popup()).shadow(toast_shadow())
205 }
206}
207
208impl<T: Styled + Sized> ElevatedSurface for T {}
209
146pub fn font_family() -> SharedString {
210pub fn font_family() -> SharedString {
147 FONT_FAMILY.into()
211 FONT_FAMILY.into()
148}
212}
@@ -341,11 +405,32 @@ pub fn avatar_palette_len() -> usize {
341
405
342#[cfg(test)]
406#[cfg(test)]
343mod tests {
407mod tests {
344 use super::{avatar_color, avatar_palette_len};
408 use super::{POPUP, POPUP_HOVER, POPUP_NESTED, avatar_color, avatar_palette_len, color, elevation_tokens};
345
409
346 #[test]
410 #[test]
347 fn avatar_colors_wrap_around_the_palette() {
411 fn avatar_colors_wrap_around_the_palette() {
348 assert_eq!(avatar_color(0), avatar_color(avatar_palette_len()));
412 assert_eq!(avatar_color(0), avatar_color(avatar_palette_len()));
349 assert_ne!(avatar_color(0), avatar_color(1));
413 assert_ne!(avatar_color(0), avatar_color(1));
350 }
414 }
415
416 #[test]
417 fn flyout_over_a_dialog_takes_a_lighter_fill_than_the_dialog() {
418 let tokens = elevation_tokens();
419 assert_eq!(tokens.dialog.fill, color(POPUP));
420 assert_eq!(tokens.flyout_at(0).fill, color(POPUP));
421 let nested = tokens.flyout_at(1);
422 assert_eq!(nested.fill, color(POPUP_NESTED));
423 assert!(nested.fill.l > tokens.dialog.fill.l);
424 assert!(nested.hover.l > nested.fill.l);
425 assert_ne!(nested.fill, color(POPUP_HOVER));
426 }
427
428 #[test]
429 fn fluent_shadow_blur_is_halved_for_gpui() {
430 let shadow = super::flyout_shadow();
431 assert_eq!(shadow[0].blur_radius, gpui_kit::px(1.));
432 assert_eq!(shadow[1].offset.y, gpui_kit::px(8.));
433 assert_eq!(shadow[1].blur_radius, gpui_kit::px(8.));
434 assert_eq!(super::dialog_shadow()[1].blur_radius, gpui_kit::px(32.));
435 }
351}
436}
crates/app/src/agents/start_dialog.rs +2 −2
@@ -20,7 +20,7 @@ use super::{
20 20 mcp_bridge, message_context, raise_notice, runs_handle, start_run, start_run_when_mcp_ready,
21 21 };
22 22 use crate::app_state::AppState;
23 use crate::theme;
23 use crate::theme::{self, ElevatedSurface as _};
24 24 use crate::views::widgets::{icon, symbol};
25 25
26 26 const CARD_WIDTH: f32 = 520.;
@@ -661,7 +661,7 @@ impl Render for StartDialog {
661 661 .p(px(CARD_PADDING))
662 662 .gap(px(SECTION_GAP))
663 663 .rounded(px(CARD_RADIUS))
664 .bg(theme::popup())
664 .dialog_surface()
665 665 .text_color(theme::text())
666 666 .occlude()
667 667 .capture_key_down(cx.listener(Self::on_key_down))
@@ -20,7 +20,7 @@ use super::{
20 mcp_bridge, message_context, raise_notice, runs_handle, start_run, start_run_when_mcp_ready,
20 mcp_bridge, message_context, raise_notice, runs_handle, start_run, start_run_when_mcp_ready,
21};
21};
22use crate::app_state::AppState;
22use crate::app_state::AppState;
23use crate::theme;
23use crate::theme::{self, ElevatedSurface as _};
24use crate::views::widgets::{icon, symbol};
24use crate::views::widgets::{icon, symbol};
25
25
26const CARD_WIDTH: f32 = 520.;
26const CARD_WIDTH: f32 = 520.;
@@ -661,7 +661,7 @@ impl Render for StartDialog {
661 .p(px(CARD_PADDING))
661 .p(px(CARD_PADDING))
662 .gap(px(SECTION_GAP))
662 .gap(px(SECTION_GAP))
663 .rounded(px(CARD_RADIUS))
663 .rounded(px(CARD_RADIUS))
664 .bg(theme::popup())
664 .dialog_surface()
665 .text_color(theme::text())
665 .text_color(theme::text())
666 .occlude()
666 .occlude()
667 .capture_key_down(cx.listener(Self::on_key_down))
667 .capture_key_down(cx.listener(Self::on_key_down))
crates/app/src/views/call_extras.rs +2 −2
@@ -16,7 +16,7 @@ use super::transfer_picker::{PickerMode, TransferPicker};
16 16 use super::widgets::icon;
17 17 use crate::app_state::AppState;
18 18 use crate::call::{BackgroundPick, CallModel, RecordAction, RecordingChip};
19 use crate::theme;
19 use crate::theme::{self, ElevatedSurface as _};
20 20
21 21 const STAGE_RADIUS: f32 = 12.;
22 22 const THUMBNAIL_WIDTH: f32 = 64.;
@@ -242,7 +242,7 @@ pub fn consent_overlay(app: &Entity<AppState>, model: &CallModel) -> Option<AnyE
242 242 .p(px(20.))
243 243 .gap(px(12.))
244 244 .rounded(px(10.))
245 .bg(theme::popup())
245 .dialog_surface()
246 246 .text_color(theme::text())
247 247 .occlude()
248 248 .child(
@@ -16,7 +16,7 @@ use super::transfer_picker::{PickerMode, TransferPicker};
16use super::widgets::icon;
16use super::widgets::icon;
17use crate::app_state::AppState;
17use crate::app_state::AppState;
18use crate::call::{BackgroundPick, CallModel, RecordAction, RecordingChip};
18use crate::call::{BackgroundPick, CallModel, RecordAction, RecordingChip};
19use crate::theme;
19use crate::theme::{self, ElevatedSurface as _};
20
20
21const STAGE_RADIUS: f32 = 12.;
21const STAGE_RADIUS: f32 = 12.;
22const THUMBNAIL_WIDTH: f32 = 64.;
22const THUMBNAIL_WIDTH: f32 = 64.;
@@ -242,7 +242,7 @@ pub fn consent_overlay(app: &Entity<AppState>, model: &CallModel) -> Option<AnyE
242 .p(px(20.))
242 .p(px(20.))
243 .gap(px(12.))
243 .gap(px(12.))
244 .rounded(px(10.))
244 .rounded(px(10.))
245 .bg(theme::popup())
245 .dialog_surface()
246 .text_color(theme::text())
246 .text_color(theme::text())
247 .occlude()
247 .occlude()
248 .child(
248 .child(
crates/app/src/views/call_mini.rs +1 −1
@@ -121,7 +121,7 @@ impl Render for CallMiniView {
121 121 .border_2()
122 122 .border_color(border)
123 123 .text_color(theme::text())
124 .shadow_lg()
124 .shadow(theme::flyout_shadow())
125 125 .cursor_pointer()
126 126 .on_click(move |_, _, cx| {
127 127 open_app.update(cx, |state, cx| state.show_call(true, cx));
@@ -121,7 +121,7 @@ impl Render for CallMiniView {
121 .border_2()
121 .border_2()
122 .border_color(border)
122 .border_color(border)
123 .text_color(theme::text())
123 .text_color(theme::text())
124 .shadow_lg()
124 .shadow(theme::flyout_shadow())
125 .cursor_pointer()
125 .cursor_pointer()
126 .on_click(move |_, _, cx| {
126 .on_click(move |_, _, cx| {
127 open_app.update(cx, |state, cx| state.show_call(true, cx));
127 open_app.update(cx, |state, cx| state.show_call(true, cx));
crates/app/src/views/call_people.rs +1 −1
@@ -656,7 +656,7 @@ pub fn options_dialog(app: &Entity<AppState>, call: &ActiveCall) -> Option<AnyEl
656 656 .border_1()
657 657 .border_color(theme::border_strong())
658 658 .text_color(theme::text())
659 .shadow_lg()
659 .shadow(theme::dialog_shadow())
660 660 .occlude()
661 661 .child(
662 662 div()
@@ -656,7 +656,7 @@ pub fn options_dialog(app: &Entity<AppState>, call: &ActiveCall) -> Option<AnyEl
656 .border_1()
656 .border_1()
657 .border_color(theme::border_strong())
657 .border_color(theme::border_strong())
658 .text_color(theme::text())
658 .text_color(theme::text())
659 .shadow_lg()
659 .shadow(theme::dialog_shadow())
660 .occlude()
660 .occlude()
661 .child(
661 .child(
662 div()
662 div()
crates/app/src/views/composer.rs +2 −2
@@ -53,7 +53,7 @@ pub use crate::outgoing::{EditPreview, Outgoing, ReplyPreview};
53 53 use crate::remote_image::RemoteImage;
54 54 use crate::runtime;
55 55 use crate::scheduled_rows::scheduled_label;
56 use crate::theme;
56 use crate::theme::{self, ElevatedSurface as _};
57 57 use crate::typing::OutgoingTyping;
58 58
59 59 const MIN_ROWS: usize = 1;
@@ -2154,7 +2154,7 @@ impl Composer {
2154 2154 .w(px(POPUP_WIDTH))
2155 2155 .py(px(6.))
2156 2156 .rounded(px(10.))
2157 .bg(theme::popup())
2157 .flyout_surface()
2158 2158 .occlude()
2159 2159 .children(rows)
2160 2160 .into_any_element(),
@@ -53,7 +53,7 @@ pub use crate::outgoing::{EditPreview, Outgoing, ReplyPreview};
53use crate::remote_image::RemoteImage;
53use crate::remote_image::RemoteImage;
54use crate::runtime;
54use crate::runtime;
55use crate::scheduled_rows::scheduled_label;
55use crate::scheduled_rows::scheduled_label;
56use crate::theme;
56use crate::theme::{self, ElevatedSurface as _};
57use crate::typing::OutgoingTyping;
57use crate::typing::OutgoingTyping;
58
58
59const MIN_ROWS: usize = 1;
59const MIN_ROWS: usize = 1;
@@ -2154,7 +2154,7 @@ impl Composer {
2154 .w(px(POPUP_WIDTH))
2154 .w(px(POPUP_WIDTH))
2155 .py(px(6.))
2155 .py(px(6.))
2156 .rounded(px(10.))
2156 .rounded(px(10.))
2157 .bg(theme::popup())
2157 .flyout_surface()
2158 .occlude()
2158 .occlude()
2159 .children(rows)
2159 .children(rows)
2160 .into_any_element(),
2160 .into_any_element(),
crates/app/src/views/composer/schedule.rs +2 −2
@@ -10,7 +10,7 @@ use crate::schedule_time::{
10 10 DayChoice, Preset, PresetKind, ScheduleError, custom_time, day_choices, default_custom_time,
11 11 format_time, parse_time, presets, step_time, validate,
12 12 };
13 use crate::theme;
13 use crate::theme::{self, ElevatedSurface as _};
14 14 use crate::views::widgets::symbol;
15 15
16 16 const MENU_WIDTH: f32 = 190.;
@@ -317,7 +317,7 @@ impl Composer {
317 317 }))
318 318 .p(px(4.))
319 319 .rounded(px(10.))
320 .bg(theme::popup())
320 .flyout_surface()
321 321 .occlude()
322 322 .on_mouse_down_out(
323 323 cx.listener(|this, _, window, cx| this.close_schedule(window, cx)),
@@ -10,7 +10,7 @@ use crate::schedule_time::{
10 DayChoice, Preset, PresetKind, ScheduleError, custom_time, day_choices, default_custom_time,
10 DayChoice, Preset, PresetKind, ScheduleError, custom_time, day_choices, default_custom_time,
11 format_time, parse_time, presets, step_time, validate,
11 format_time, parse_time, presets, step_time, validate,
12};
12};
13use crate::theme;
13use crate::theme::{self, ElevatedSurface as _};
14use crate::views::widgets::symbol;
14use crate::views::widgets::symbol;
15
15
16const MENU_WIDTH: f32 = 190.;
16const MENU_WIDTH: f32 = 190.;
@@ -317,7 +317,7 @@ impl Composer {
317 }))
317 }))
318 .p(px(4.))
318 .p(px(4.))
319 .rounded(px(10.))
319 .rounded(px(10.))
320 .bg(theme::popup())
320 .flyout_surface()
321 .occlude()
321 .occlude()
322 .on_mouse_down_out(
322 .on_mouse_down_out(
323 cx.listener(|this, _, window, cx| this.close_schedule(window, cx)),
323 cx.listener(|this, _, window, cx| this.close_schedule(window, cx)),
crates/app/src/views/dialog_overlay.rs +2 −2
@@ -5,7 +5,7 @@ use super::adaptive_card::card_view;
5 5 use super::widgets::symbol;
6 6 use crate::app_state::{AppHandle, AppState};
7 7 use crate::card_state::TaskDialogState;
8 use crate::theme;
8 use crate::theme::{self, ElevatedSurface as _};
9 9
10 10 const BACKDROP_OPACITY: f32 = 0.55;
11 11 const PANEL_MARGIN: f32 = 32.;
@@ -56,7 +56,7 @@ fn panel(dialog: &TaskDialogState, cx: &App) -> Div {
56 56 .p(px(PANEL_PADDING))
57 57 .gap(px(HEADER_GAP))
58 58 .rounded(px(PANEL_RADIUS))
59 .bg(theme::popup())
59 .dialog_surface()
60 60 .text_color(theme::text())
61 61 .occlude()
62 62 .child(
@@ -5,7 +5,7 @@ use super::adaptive_card::card_view;
5use super::widgets::symbol;
5use super::widgets::symbol;
6use crate::app_state::{AppHandle, AppState};
6use crate::app_state::{AppHandle, AppState};
7use crate::card_state::TaskDialogState;
7use crate::card_state::TaskDialogState;
8use crate::theme;
8use crate::theme::{self, ElevatedSurface as _};
9
9
10const BACKDROP_OPACITY: f32 = 0.55;
10const BACKDROP_OPACITY: f32 = 0.55;
11const PANEL_MARGIN: f32 = 32.;
11const PANEL_MARGIN: f32 = 32.;
@@ -56,7 +56,7 @@ fn panel(dialog: &TaskDialogState, cx: &App) -> Div {
56 .p(px(PANEL_PADDING))
56 .p(px(PANEL_PADDING))
57 .gap(px(HEADER_GAP))
57 .gap(px(HEADER_GAP))
58 .rounded(px(PANEL_RADIUS))
58 .rounded(px(PANEL_RADIUS))
59 .bg(theme::popup())
59 .dialog_surface()
60 .text_color(theme::text())
60 .text_color(theme::text())
61 .occlude()
61 .occlude()
62 .child(
62 .child(
crates/app/src/views/emoji_popup.rs +2 −2
@@ -7,7 +7,7 @@ use gpui_kit::*;
7 7 use super::widgets::symbol;
8 8 use crate::emoji::Match;
9 9 use crate::emoticons;
10 use crate::theme;
10 use crate::theme::{self, ElevatedSurface as _};
11 11
12 12 pub const LIMIT: usize = 40;
13 13 const WIDTH: f32 = 300.;
@@ -183,7 +183,7 @@ pub fn render(
183 183 .w(px(WIDTH))
184 184 .p(px(4.))
185 185 .rounded(px(10.))
186 .bg(theme::popup())
186 .flyout_surface()
187 187 .occlude()
188 188 .child(
189 189 v_flex()
@@ -7,7 +7,7 @@ use gpui_kit::*;
7use super::widgets::symbol;
7use super::widgets::symbol;
8use crate::emoji::Match;
8use crate::emoji::Match;
9use crate::emoticons;
9use crate::emoticons;
10use crate::theme;
10use crate::theme::{self, ElevatedSurface as _};
11
11
12pub const LIMIT: usize = 40;
12pub const LIMIT: usize = 40;
13const WIDTH: f32 = 300.;
13const WIDTH: f32 = 300.;
@@ -183,7 +183,7 @@ pub fn render(
183 .w(px(WIDTH))
183 .w(px(WIDTH))
184 .p(px(4.))
184 .p(px(4.))
185 .rounded(px(10.))
185 .rounded(px(10.))
186 .bg(theme::popup())
186 .flyout_surface()
187 .occlude()
187 .occlude()
188 .child(
188 .child(
189 v_flex()
189 v_flex()
crates/app/src/views/format_toolbar.rs +2 −2
@@ -7,7 +7,7 @@ use gpui_kit::*;
7 7 use teams_core::FormatState;
8 8
9 9 use super::widgets::symbol;
10 use crate::theme;
10 use crate::theme::{self, ElevatedSurface as _};
11 11
12 12 const PADDING: f32 = 4.;
13 13 const BUTTON: f32 = 28.;
@@ -339,7 +339,7 @@ pub fn render(placement: Placement, mode: Mode<'_>) -> AnyElement {
339 339 div()
340 340 .p(px(PADDING))
341 341 .rounded(px(10.))
342 .bg(theme::popup())
342 .flyout_surface()
343 343 .child(content),
344 344 )
345 345 .child(arrow(placement.arrow_x)),
@@ -7,7 +7,7 @@ use gpui_kit::*;
7use teams_core::FormatState;
7use teams_core::FormatState;
8
8
9use super::widgets::symbol;
9use super::widgets::symbol;
10use crate::theme;
10use crate::theme::{self, ElevatedSurface as _};
11
11
12const PADDING: f32 = 4.;
12const PADDING: f32 = 4.;
13const BUTTON: f32 = 28.;
13const BUTTON: f32 = 28.;
@@ -339,7 +339,7 @@ pub fn render(placement: Placement, mode: Mode<'_>) -> AnyElement {
339 div()
339 div()
340 .p(px(PADDING))
340 .p(px(PADDING))
341 .rounded(px(10.))
341 .rounded(px(10.))
342 .bg(theme::popup())
342 .flyout_surface()
343 .child(content),
343 .child(content),
344 )
344 )
345 .child(arrow(placement.arrow_x)),
345 .child(arrow(placement.arrow_x)),
crates/app/src/views/forward_dialog.rs +2 −2
@@ -15,7 +15,7 @@ use crate::fuzzy;
15 15 use crate::message_actions::ForwardSource;
16 16 use crate::notice::short_error;
17 17 use crate::runtime;
18 use crate::theme;
18 use crate::theme::{self, ElevatedSurface as _};
19 19
20 20 const MAX_RESULTS: usize = 8;
21 21 const CARD_WIDTH: f32 = 480.;
@@ -461,7 +461,7 @@ impl Render for ForwardDialog {
461 461 .p(px(CARD_PADDING))
462 462 .gap(px(SECTION_GAP))
463 463 .rounded(px(CARD_RADIUS))
464 .bg(theme::popup())
464 .dialog_surface()
465 465 .text_color(theme::text())
466 466 .occlude()
467 467 .on_key_down(cx.listener(Self::on_key_down))
@@ -15,7 +15,7 @@ use crate::fuzzy;
15use crate::message_actions::ForwardSource;
15use crate::message_actions::ForwardSource;
16use crate::notice::short_error;
16use crate::notice::short_error;
17use crate::runtime;
17use crate::runtime;
18use crate::theme;
18use crate::theme::{self, ElevatedSurface as _};
19
19
20const MAX_RESULTS: usize = 8;
20const MAX_RESULTS: usize = 8;
21const CARD_WIDTH: f32 = 480.;
21const CARD_WIDTH: f32 = 480.;
@@ -461,7 +461,7 @@ impl Render for ForwardDialog {
461 .p(px(CARD_PADDING))
461 .p(px(CARD_PADDING))
462 .gap(px(SECTION_GAP))
462 .gap(px(SECTION_GAP))
463 .rounded(px(CARD_RADIUS))
463 .rounded(px(CARD_RADIUS))
464 .bg(theme::popup())
464 .dialog_surface()
465 .text_color(theme::text())
465 .text_color(theme::text())
466 .occlude()
466 .occlude()
467 .on_key_down(cx.listener(Self::on_key_down))
467 .on_key_down(cx.listener(Self::on_key_down))
crates/app/src/views/message_actions.rs +2 −2
@@ -16,7 +16,7 @@ use super::reaction_picker::{DoneHandler, PickHandler, ReactionPicker};
16 16 use super::toolbar_placement::{HoverChange, TOOLBAR_HEIGHT, toolbar_slot};
17 17 use super::widgets::icon;
18 18 use crate::rows::reaction_glyph;
19 use crate::theme;
19 use crate::theme::{self, ElevatedSurface as _};
20 20
21 21 const BAR_BUTTON: f32 = 30.;
22 22 const BAR_PADDING: f32 = 3.;
@@ -319,7 +319,7 @@ pub fn message_toolbar(menu: MessageMenu, cx: &App) -> AnyElement {
319 319 .gap(px(1.))
320 320 .items_center()
321 321 .rounded(px(10.))
322 .bg(theme::popup())
322 .flyout_surface()
323 323 .on_mouse_down(MouseButton::Left, |_, _, cx| {
324 324 GlobalState::suppress_text_selection(cx)
325 325 })
@@ -16,7 +16,7 @@ use super::reaction_picker::{DoneHandler, PickHandler, ReactionPicker};
16use super::toolbar_placement::{HoverChange, TOOLBAR_HEIGHT, toolbar_slot};
16use super::toolbar_placement::{HoverChange, TOOLBAR_HEIGHT, toolbar_slot};
17use super::widgets::icon;
17use super::widgets::icon;
18use crate::rows::reaction_glyph;
18use crate::rows::reaction_glyph;
19use crate::theme;
19use crate::theme::{self, ElevatedSurface as _};
20
20
21const BAR_BUTTON: f32 = 30.;
21const BAR_BUTTON: f32 = 30.;
22const BAR_PADDING: f32 = 3.;
22const BAR_PADDING: f32 = 3.;
@@ -319,7 +319,7 @@ pub fn message_toolbar(menu: MessageMenu, cx: &App) -> AnyElement {
319 .gap(px(1.))
319 .gap(px(1.))
320 .items_center()
320 .items_center()
321 .rounded(px(10.))
321 .rounded(px(10.))
322 .bg(theme::popup())
322 .flyout_surface()
323 .on_mouse_down(MouseButton::Left, |_, _, cx| {
323 .on_mouse_down(MouseButton::Left, |_, _, cx| {
324 GlobalState::suppress_text_selection(cx)
324 GlobalState::suppress_text_selection(cx)
325 })
325 })
crates/app/src/views/new_chat.rs +2 −2
@@ -18,7 +18,7 @@ use super::widgets::icon;
18 18 use crate::app_state::AppState;
19 19 use crate::data::{self, Directory, Person};
20 20 use crate::runtime;
21 use crate::theme;
21 use crate::theme::{self, ElevatedSurface as _};
22 22
23 23 const SEARCH_DEBOUNCE: Duration = Duration::from_millis(200);
24 24 const SUGGESTED_LIMIT: usize = 6;
@@ -527,7 +527,7 @@ impl NewChatDraft {
527 527 .mt(px(4.))
528 528 .p(px(6.))
529 529 .rounded(px(10.))
530 .bg(theme::popup())
530 .flyout_surface()
531 531 .occlude()
532 532 .when(!results_empty, |popup| {
533 533 popup.child(
@@ -18,7 +18,7 @@ use super::widgets::icon;
18use crate::app_state::AppState;
18use crate::app_state::AppState;
19use crate::data::{self, Directory, Person};
19use crate::data::{self, Directory, Person};
20use crate::runtime;
20use crate::runtime;
21use crate::theme;
21use crate::theme::{self, ElevatedSurface as _};
22
22
23const SEARCH_DEBOUNCE: Duration = Duration::from_millis(200);
23const SEARCH_DEBOUNCE: Duration = Duration::from_millis(200);
24const SUGGESTED_LIMIT: usize = 6;
24const SUGGESTED_LIMIT: usize = 6;
@@ -527,7 +527,7 @@ impl NewChatDraft {
527 .mt(px(4.))
527 .mt(px(4.))
528 .p(px(6.))
528 .p(px(6.))
529 .rounded(px(10.))
529 .rounded(px(10.))
530 .bg(theme::popup())
530 .flyout_surface()
531 .occlude()
531 .occlude()
532 .when(!results_empty, |popup| {
532 .when(!results_empty, |popup| {
533 popup.child(
533 popup.child(
crates/app/src/views/profile_card.rs +2 −2
@@ -17,7 +17,7 @@ use crate::profile_model::{
17 17 ContactKind, ContactRow, StatusBox, contact_rows, has_organization, local_time_label,
18 18 mailto_url, status_box, status_line, work_location_label,
19 19 };
20 use crate::theme;
20 use crate::theme::{self, ElevatedSurface as _};
21 21
22 22 const CARD_WIDTH: f32 = 340.;
23 23 const CARD_RADIUS: f32 = 10.;
@@ -624,7 +624,7 @@ impl Render for ProfileCard {
624 624 .p(px(CARD_PADDING))
625 625 .gap(px(CARD_GAP))
626 626 .rounded(px(CARD_RADIUS))
627 .bg(theme::popup())
627 .flyout_surface()
628 628 .text_color(theme::text())
629 629 .occlude()
630 630 .on_key_down(cx.listener(Self::on_key_down))
@@ -17,7 +17,7 @@ use crate::profile_model::{
17 ContactKind, ContactRow, StatusBox, contact_rows, has_organization, local_time_label,
17 ContactKind, ContactRow, StatusBox, contact_rows, has_organization, local_time_label,
18 mailto_url, status_box, status_line, work_location_label,
18 mailto_url, status_box, status_line, work_location_label,
19};
19};
20use crate::theme;
20use crate::theme::{self, ElevatedSurface as _};
21
21
22const CARD_WIDTH: f32 = 340.;
22const CARD_WIDTH: f32 = 340.;
23const CARD_RADIUS: f32 = 10.;
23const CARD_RADIUS: f32 = 10.;
@@ -624,7 +624,7 @@ impl Render for ProfileCard {
624 .p(px(CARD_PADDING))
624 .p(px(CARD_PADDING))
625 .gap(px(CARD_GAP))
625 .gap(px(CARD_GAP))
626 .rounded(px(CARD_RADIUS))
626 .rounded(px(CARD_RADIUS))
627 .bg(theme::popup())
627 .flyout_surface()
628 .text_color(theme::text())
628 .text_color(theme::text())
629 .occlude()
629 .occlude()
630 .on_key_down(cx.listener(Self::on_key_down))
630 .on_key_down(cx.listener(Self::on_key_down))
crates/app/src/views/reaction_pills.rs +2 −2
@@ -14,7 +14,7 @@ use crate::reaction_model::{
14 14 reaction_time_label, shows_faces,
15 15 };
16 16 use crate::rows::ReactionChip;
17 use crate::theme;
17 use crate::theme::{self, ElevatedSurface as _};
18 18
19 19 const PILL_HEIGHT: f32 = 24.;
20 20 const PILL_EMOJI_SIZE: f32 = 14.;
@@ -249,7 +249,7 @@ fn popover(
249 249 .p(px(6.))
250 250 .gap(px(4.))
251 251 .rounded(px(10.))
252 .bg(theme::popup())
252 .flyout_surface()
253 253 .occlude()
254 254 .on_mouse_down_out(move |_, _, cx| close(cx))
255 255 .on_mouse_down(MouseButton::Left, |_, _, cx| {
@@ -14,7 +14,7 @@ use crate::reaction_model::{
14 reaction_time_label, shows_faces,
14 reaction_time_label, shows_faces,
15};
15};
16use crate::rows::ReactionChip;
16use crate::rows::ReactionChip;
17use crate::theme;
17use crate::theme::{self, ElevatedSurface as _};
18
18
19const PILL_HEIGHT: f32 = 24.;
19const PILL_HEIGHT: f32 = 24.;
20const PILL_EMOJI_SIZE: f32 = 14.;
20const PILL_EMOJI_SIZE: f32 = 14.;
@@ -249,7 +249,7 @@ fn popover(
249 .p(px(6.))
249 .p(px(6.))
250 .gap(px(4.))
250 .gap(px(4.))
251 .rounded(px(10.))
251 .rounded(px(10.))
252 .bg(theme::popup())
252 .flyout_surface()
253 .occlude()
253 .occlude()
254 .on_mouse_down_out(move |_, _, cx| close(cx))
254 .on_mouse_down_out(move |_, _, cx| close(cx))
255 .on_mouse_down(MouseButton::Left, |_, _, cx| {
255 .on_mouse_down(MouseButton::Left, |_, _, cx| {
crates/app/src/views/scheduled_toolbar.rs +2 −2
@@ -6,7 +6,7 @@ use gpui_kit::*;
6 6 use super::message_actions::{Action, bar_button};
7 7 use super::toolbar_placement::{HoverChange, TOOLBAR_HEIGHT, toolbar_slot};
8 8 use super::widgets::icon;
9 use crate::theme;
9 use crate::theme::{self, ElevatedSurface as _};
10 10
11 11 pub struct ScheduledMenu {
12 12 pub key: String,
@@ -43,7 +43,7 @@ pub fn scheduled_toolbar(menu: ScheduledMenu) -> AnyElement {
43 43 .gap(px(1.))
44 44 .items_center()
45 45 .rounded(px(10.))
46 .bg(theme::popup())
46 .flyout_surface()
47 47 .on_mouse_down(MouseButton::Left, |_, _, cx| {
48 48 GlobalState::suppress_text_selection(cx)
49 49 })
@@ -6,7 +6,7 @@ use gpui_kit::*;
6use super::message_actions::{Action, bar_button};
6use super::message_actions::{Action, bar_button};
7use super::toolbar_placement::{HoverChange, TOOLBAR_HEIGHT, toolbar_slot};
7use super::toolbar_placement::{HoverChange, TOOLBAR_HEIGHT, toolbar_slot};
8use super::widgets::icon;
8use super::widgets::icon;
9use crate::theme;
9use crate::theme::{self, ElevatedSurface as _};
10
10
11pub struct ScheduledMenu {
11pub struct ScheduledMenu {
12 pub key: String,
12 pub key: String,
@@ -43,7 +43,7 @@ pub fn scheduled_toolbar(menu: ScheduledMenu) -> AnyElement {
43 .gap(px(1.))
43 .gap(px(1.))
44 .items_center()
44 .items_center()
45 .rounded(px(10.))
45 .rounded(px(10.))
46 .bg(theme::popup())
46 .flyout_surface()
47 .on_mouse_down(MouseButton::Left, |_, _, cx| {
47 .on_mouse_down(MouseButton::Left, |_, _, cx| {
48 GlobalState::suppress_text_selection(cx)
48 GlobalState::suppress_text_selection(cx)
49 })
49 })
crates/app/src/views/shell.rs +12 −1
@@ -1,6 +1,6 @@
1 1 use std::sync::Arc;
2 2
3 use gpui_kit::component::{h_flex, v_flex};
3 use gpui_kit::component::{elevation, h_flex, v_flex};
4 4 use gpui_kit::*;
5 5
6 6 use super::activity_panel::{ActivityPanel, ActivityPanelEvent};
@@ -762,6 +762,17 @@ impl AppShell {
762 762
763 763 impl Render for AppShell {
764 764 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
765 let open_dialogs = [
766 self.state.read(cx).task_dialog.is_some(),
767 self.forward_dialog.is_some(),
768 self.status_dialog.is_some(),
769 self.shortcuts_dialog.is_some(),
770 self.agent_dialog.is_some(),
771 ]
772 .into_iter()
773 .filter(|open| *open)
774 .count();
775 elevation::set_app_modal_layers(window, open_dialogs, cx);
765 776 if let Some(dialog) = self
766 777 .state
767 778 .read(cx)
@@ -1,6 +1,6 @@
1use std::sync::Arc;
1use std::sync::Arc;
2
2
3use gpui_kit::component::{h_flex, v_flex};
3use gpui_kit::component::{elevation, h_flex, v_flex};
4use gpui_kit::*;
4use gpui_kit::*;
5
5
6use super::activity_panel::{ActivityPanel, ActivityPanelEvent};
6use super::activity_panel::{ActivityPanel, ActivityPanelEvent};
@@ -762,6 +762,17 @@ impl AppShell {
762
762
763impl Render for AppShell {
763impl Render for AppShell {
764 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
764 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
765 let open_dialogs = [
766 self.state.read(cx).task_dialog.is_some(),
767 self.forward_dialog.is_some(),
768 self.status_dialog.is_some(),
769 self.shortcuts_dialog.is_some(),
770 self.agent_dialog.is_some(),
771 ]
772 .into_iter()
773 .filter(|open| *open)
774 .count();
775 elevation::set_app_modal_layers(window, open_dialogs, cx);
765 if let Some(dialog) = self
776 if let Some(dialog) = self
766 .state
777 .state
767 .read(cx)
778 .read(cx)
crates/app/src/views/shortcuts_dialog.rs +2 −2
@@ -3,7 +3,7 @@ use gpui_kit::*;
3 3
4 4 use super::shortcuts::{Group, shortcuts_in};
5 5 use super::widgets::symbol;
6 use crate::theme;
6 use crate::theme::{self, ElevatedSurface as _};
7 7
8 8 const CARD_WIDTH: f32 = 520.;
9 9 const CARD_RADIUS: f32 = 10.;
@@ -137,7 +137,7 @@ impl Render for ShortcutsDialog {
137 137 .p(px(CARD_PADDING))
138 138 .gap(px(SECTION_GAP))
139 139 .rounded(px(CARD_RADIUS))
140 .bg(theme::popup())
140 .dialog_surface()
141 141 .text_color(theme::text())
142 142 .occlude()
143 143 .capture_key_down(cx.listener(Self::on_key_down))
@@ -3,7 +3,7 @@ use gpui_kit::*;
3
3
4use super::shortcuts::{Group, shortcuts_in};
4use super::shortcuts::{Group, shortcuts_in};
5use super::widgets::symbol;
5use super::widgets::symbol;
6use crate::theme;
6use crate::theme::{self, ElevatedSurface as _};
7
7
8const CARD_WIDTH: f32 = 520.;
8const CARD_WIDTH: f32 = 520.;
9const CARD_RADIUS: f32 = 10.;
9const CARD_RADIUS: f32 = 10.;
@@ -137,7 +137,7 @@ impl Render for ShortcutsDialog {
137 .p(px(CARD_PADDING))
137 .p(px(CARD_PADDING))
138 .gap(px(SECTION_GAP))
138 .gap(px(SECTION_GAP))
139 .rounded(px(CARD_RADIUS))
139 .rounded(px(CARD_RADIUS))
140 .bg(theme::popup())
140 .dialog_surface()
141 .text_color(theme::text())
141 .text_color(theme::text())
142 .occlude()
142 .occlude()
143 .capture_key_down(cx.listener(Self::on_key_down))
143 .capture_key_down(cx.listener(Self::on_key_down))
crates/app/src/views/skin_tone_choices.rs +2 −5
@@ -7,7 +7,7 @@ use gpui_kit::*;
7 7
8 8 use super::widgets::{Corner, corner_badge};
9 9 use crate::emoticons::{SKIN_TONE_COUNT, with_tone};
10 use crate::theme;
10 use crate::theme::{self, ElevatedSurface as _};
11 11
12 12 const CHOICE_SIZE: f32 = 32.;
13 13 const CHOICE_GLYPH_SIZE: f32 = 20.;
@@ -70,10 +70,7 @@ pub fn tone_choices(
70 70 .gap(px(PANEL_GAP))
71 71 .p(px(PANEL_PADDING))
72 72 .rounded(px(8.))
73 .bg(theme::popup())
74 .border_1()
75 .border_color(theme::border_strong())
76 .shadow_md()
73 .nested_flyout_surface()
77 74 .occlude()
78 75 .on_mouse_down_out(move |_, window, cx| dismiss(window, cx))
79 76 .children(choices),
@@ -7,7 +7,7 @@ use gpui_kit::*;
7
7
8use super::widgets::{Corner, corner_badge};
8use super::widgets::{Corner, corner_badge};
9use crate::emoticons::{SKIN_TONE_COUNT, with_tone};
9use crate::emoticons::{SKIN_TONE_COUNT, with_tone};
10use crate::theme;
10use crate::theme::{self, ElevatedSurface as _};
11
11
12const CHOICE_SIZE: f32 = 32.;
12const CHOICE_SIZE: f32 = 32.;
13const CHOICE_GLYPH_SIZE: f32 = 20.;
13const CHOICE_GLYPH_SIZE: f32 = 20.;
@@ -70,10 +70,7 @@ pub fn tone_choices(
70 .gap(px(PANEL_GAP))
70 .gap(px(PANEL_GAP))
71 .p(px(PANEL_PADDING))
71 .p(px(PANEL_PADDING))
72 .rounded(px(8.))
72 .rounded(px(8.))
73 .bg(theme::popup())
73 .nested_flyout_surface()
74 .border_1()
75 .border_color(theme::border_strong())
76 .shadow_md()
77 .occlude()
74 .occlude()
78 .on_mouse_down_out(move |_, window, cx| dismiss(window, cx))
75 .on_mouse_down_out(move |_, window, cx| dismiss(window, cx))
79 .children(choices),
76 .children(choices),
crates/app/src/views/status_message_dialog.rs +2 −2
@@ -15,7 +15,7 @@ use teams_core::StatusNote;
15 15 use super::widgets::symbol;
16 16 use crate::app_state::AppState;
17 17 use crate::own_status::{NOTE_DURATIONS, NOTE_LIMIT, NoteDuration, clamp_note};
18 use crate::theme;
18 use crate::theme::{self, ElevatedSurface as _};
19 19
20 20 const CARD_WIDTH: f32 = 440.;
21 21 const CARD_RADIUS: f32 = 10.;
@@ -266,7 +266,7 @@ impl Render for StatusMessageDialog {
266 266 .p(px(CARD_PADDING))
267 267 .gap(px(SECTION_GAP))
268 268 .rounded(px(CARD_RADIUS))
269 .bg(theme::popup())
269 .dialog_surface()
270 270 .text_color(theme::text())
271 271 .occlude()
272 272 .capture_key_down(cx.listener(Self::on_key_down))
@@ -15,7 +15,7 @@ use teams_core::StatusNote;
15use super::widgets::symbol;
15use super::widgets::symbol;
16use crate::app_state::AppState;
16use crate::app_state::AppState;
17use crate::own_status::{NOTE_DURATIONS, NOTE_LIMIT, NoteDuration, clamp_note};
17use crate::own_status::{NOTE_DURATIONS, NOTE_LIMIT, NoteDuration, clamp_note};
18use crate::theme;
18use crate::theme::{self, ElevatedSurface as _};
19
19
20const CARD_WIDTH: f32 = 440.;
20const CARD_WIDTH: f32 = 440.;
21const CARD_RADIUS: f32 = 10.;
21const CARD_RADIUS: f32 = 10.;
@@ -266,7 +266,7 @@ impl Render for StatusMessageDialog {
266 .p(px(CARD_PADDING))
266 .p(px(CARD_PADDING))
267 .gap(px(SECTION_GAP))
267 .gap(px(SECTION_GAP))
268 .rounded(px(CARD_RADIUS))
268 .rounded(px(CARD_RADIUS))
269 .bg(theme::popup())
269 .dialog_surface()
270 .text_color(theme::text())
270 .text_color(theme::text())
271 .occlude()
271 .occlude()
272 .capture_key_down(cx.listener(Self::on_key_down))
272 .capture_key_down(cx.listener(Self::on_key_down))
crates/app/src/views/switcher.rs +2 −2
@@ -20,7 +20,7 @@ use crate::data::{Directory, is_one_on_one};
20 20 use crate::format;
21 21 use crate::fuzzy;
22 22 use crate::sidebar_model::{AvatarSpec, avatar_for};
23 use crate::theme;
23 use crate::theme::{self, ElevatedSurface as _};
24 24
25 25 const MAX_RESULTS: usize = 9;
26 26 const MAX_RESULTS_WITH_MESSAGES: usize = 5;
@@ -488,7 +488,7 @@ impl Render for Switcher {
488 488 .w(px(CARD_WIDTH))
489 489 .max_h(px(640.))
490 490 .rounded(px(10.))
491 .bg(theme::popup())
491 .flyout_surface()
492 492 .overflow_hidden()
493 493 .on_click(|_, _, cx| cx.stop_propagation())
494 494 .on_key_down(cx.listener(Self::on_key_down))
@@ -20,7 +20,7 @@ use crate::data::{Directory, is_one_on_one};
20use crate::format;
20use crate::format;
21use crate::fuzzy;
21use crate::fuzzy;
22use crate::sidebar_model::{AvatarSpec, avatar_for};
22use crate::sidebar_model::{AvatarSpec, avatar_for};
23use crate::theme;
23use crate::theme::{self, ElevatedSurface as _};
24
24
25const MAX_RESULTS: usize = 9;
25const MAX_RESULTS: usize = 9;
26const MAX_RESULTS_WITH_MESSAGES: usize = 5;
26const MAX_RESULTS_WITH_MESSAGES: usize = 5;
@@ -488,7 +488,7 @@ impl Render for Switcher {
488 .w(px(CARD_WIDTH))
488 .w(px(CARD_WIDTH))
489 .max_h(px(640.))
489 .max_h(px(640.))
490 .rounded(px(10.))
490 .rounded(px(10.))
491 .bg(theme::popup())
491 .flyout_surface()
492 .overflow_hidden()
492 .overflow_hidden()
493 .on_click(|_, _, cx| cx.stop_propagation())
493 .on_click(|_, _, cx| cx.stop_propagation())
494 .on_key_down(cx.listener(Self::on_key_down))
494 .on_key_down(cx.listener(Self::on_key_down))
crates/app/src/views/transfer_picker.rs +1 −1
@@ -271,7 +271,7 @@ impl Render for TransferPicker {
271 271 .border_1()
272 272 .border_color(theme::border_strong())
273 273 .text_color(theme::text())
274 .shadow_lg()
274 .shadow(theme::dialog_shadow())
275 275 .occlude()
276 276 .on_key_down(cx.listener(Self::on_key_down))
277 277 .child(
@@ -271,7 +271,7 @@ impl Render for TransferPicker {
271 .border_1()
271 .border_1()
272 .border_color(theme::border_strong())
272 .border_color(theme::border_strong())
273 .text_color(theme::text())
273 .text_color(theme::text())
274 .shadow_lg()
274 .shadow(theme::dialog_shadow())
275 .occlude()
275 .occlude()
276 .on_key_down(cx.listener(Self::on_key_down))
276 .on_key_down(cx.listener(Self::on_key_down))
277 .child(
277 .child(
vendor/gpui-component/src/combobox.rs +3 −1
@@ -704,6 +704,7 @@ where
704 704 bounds,
705 705 footer_el,
706 706 dismiss_handler,
707 window,
707 708 cx,
708 709 ))
709 710 .with_priority(gpui_base::POPUP_PRIORITY),
@@ -1040,6 +1041,7 @@ fn render_popup_shell<D: SearchableListDelegate + 'static>(
1040 1041 bounds: Bounds<Pixels>,
1041 1042 footer_el: Option<AnyElement>,
1042 1043 dismiss_handler: Box<dyn Fn(&MouseDownEvent, &mut Window, &mut App) + 'static>,
1044 window: &Window,
1043 1045 cx: &mut App,
1044 1046 ) -> AnyElement {
1045 1047 let has_footer = footer_el.is_some();
@@ -1053,7 +1055,7 @@ fn render_popup_shell<D: SearchableListDelegate + 'static>(
1053 1055 Length::Auto => this.w(bounds.size.width),
1054 1056 Length::Definite(w) => this.w(w),
1055 1057 })
1056 .popover_style(cx)
1058 .popover_style(window, cx)
1057 1059 .child(
1058 1060 List::new(list)
1059 1061 .when_some(search_placeholder, |this, placeholder| {
@@ -704,6 +704,7 @@ where
704 bounds,
704 bounds,
705 footer_el,
705 footer_el,
706 dismiss_handler,
706 dismiss_handler,
707 window,
707 cx,
708 cx,
708 ))
709 ))
709 .with_priority(gpui_base::POPUP_PRIORITY),
710 .with_priority(gpui_base::POPUP_PRIORITY),
@@ -1040,6 +1041,7 @@ fn render_popup_shell<D: SearchableListDelegate + 'static>(
1040 bounds: Bounds<Pixels>,
1041 bounds: Bounds<Pixels>,
1041 footer_el: Option<AnyElement>,
1042 footer_el: Option<AnyElement>,
1042 dismiss_handler: Box<dyn Fn(&MouseDownEvent, &mut Window, &mut App) + 'static>,
1043 dismiss_handler: Box<dyn Fn(&MouseDownEvent, &mut Window, &mut App) + 'static>,
1044 window: &Window,
1043 cx: &mut App,
1045 cx: &mut App,
1044) -> AnyElement {
1046) -> AnyElement {
1045 let has_footer = footer_el.is_some();
1047 let has_footer = footer_el.is_some();
@@ -1053,7 +1055,7 @@ fn render_popup_shell<D: SearchableListDelegate + 'static>(
1053 Length::Auto => this.w(bounds.size.width),
1055 Length::Auto => this.w(bounds.size.width),
1054 Length::Definite(w) => this.w(w),
1056 Length::Definite(w) => this.w(w),
1055 })
1057 })
1056 .popover_style(cx)
1058 .popover_style(window, cx)
1057 .child(
1059 .child(
1058 List::new(list)
1060 List::new(list)
1059 .when_some(search_placeholder, |this, placeholder| {
1061 .when_some(search_placeholder, |this, placeholder| {
vendor/gpui-component/src/dialog/dialog.rs +5 −22
@@ -3,7 +3,7 @@ use gpui_base::TestSupportExt as _;
3 3 use std::{rc::Rc, sync::LazyLock, time::Duration};
4 4
5 5 use gpui::{
6 Action, Anchor, Animation, AnimationExt as _, AnyElement, App, BoxShadow, ClickEvent, Edges,
6 Action, Anchor, Animation, AnimationExt as _, AnyElement, App, ClickEvent, Edges,
7 7 FocusHandle, Hsla, InteractiveElement, IntoElement, ParentElement, Pixels, RenderOnce,
8 8 SharedString, StyleRefinement, Styled, Window, WindowControlArea, anchored, div, hsla, point,
9 9 prelude::FluentBuilder, px,
@@ -611,6 +611,8 @@ impl RenderOnce for Dialog {
611 611 1.,
612 612 ));
613 613
614 let dialog_elevation = crate::elevation::dialog(cx);
615
614 616 anchored()
615 617 .position(point(window_paddings.left, window_paddings.top))
616 618 .snap_to_window()
@@ -666,9 +668,7 @@ impl RenderOnce for Dialog {
666 668 .id(layer_ix)
667 669 .test_support()
668 670 .debug_selector(move || format!("dialog-{layer_ix}"))
669 .bg(cx.theme().tokens.background)
670 .border_1()
671 .border_color(cx.theme().border)
671 .bg(dialog_elevation.fill)
672 672 .rounded(cx.theme().radius_lg)
673 673 .min_h_24()
674 674 .pt(paddings.top)
@@ -753,24 +753,7 @@ impl RenderOnce for Dialog {
753 753 "slide-down-shadow",
754 754 animation.clone(),
755 755 move |this, delta| {
756 // This is equivalent to `shadow_xl` with an extra opacity.
757 let shadow = vec![
758 BoxShadow {
759 color: hsla(0., 0., 0., 0.1 * delta),
760 offset: point(px(0.), px(20.)),
761 blur_radius: px(25.),
762 spread_radius: px(-5.),
763 inset: false,
764 },
765 BoxShadow {
766 color: hsla(0., 0., 0., 0.1 * delta),
767 offset: point(px(0.), px(8.)),
768 blur_radius: px(10.),
769 spread_radius: px(-6.),
770 inset: false,
771 },
772 ];
773 this.shadow(shadow)
756 this.shadow(dialog_elevation.shadow_at(delta))
774 757 },
775 758 )
776 759 .text_selection_scope(selection_scope),
@@ -3,7 +3,7 @@ use gpui_base::TestSupportExt as _;
3use std::{rc::Rc, sync::LazyLock, time::Duration};
3use std::{rc::Rc, sync::LazyLock, time::Duration};
4
4
5use gpui::{
5use gpui::{
6 Action, Anchor, Animation, AnimationExt as _, AnyElement, App, BoxShadow, ClickEvent, Edges,
6 Action, Anchor, Animation, AnimationExt as _, AnyElement, App, ClickEvent, Edges,
7 FocusHandle, Hsla, InteractiveElement, IntoElement, ParentElement, Pixels, RenderOnce,
7 FocusHandle, Hsla, InteractiveElement, IntoElement, ParentElement, Pixels, RenderOnce,
8 SharedString, StyleRefinement, Styled, Window, WindowControlArea, anchored, div, hsla, point,
8 SharedString, StyleRefinement, Styled, Window, WindowControlArea, anchored, div, hsla, point,
9 prelude::FluentBuilder, px,
9 prelude::FluentBuilder, px,
@@ -611,6 +611,8 @@ impl RenderOnce for Dialog {
611 1.,
611 1.,
612 ));
612 ));
613
613
614 let dialog_elevation = crate::elevation::dialog(cx);
615
614 anchored()
616 anchored()
615 .position(point(window_paddings.left, window_paddings.top))
617 .position(point(window_paddings.left, window_paddings.top))
616 .snap_to_window()
618 .snap_to_window()
@@ -666,9 +668,7 @@ impl RenderOnce for Dialog {
666 .id(layer_ix)
668 .id(layer_ix)
667 .test_support()
669 .test_support()
668 .debug_selector(move || format!("dialog-{layer_ix}"))
670 .debug_selector(move || format!("dialog-{layer_ix}"))
669 .bg(cx.theme().tokens.background)
671 .bg(dialog_elevation.fill)
670 .border_1()
671 .border_color(cx.theme().border)
672 .rounded(cx.theme().radius_lg)
672 .rounded(cx.theme().radius_lg)
673 .min_h_24()
673 .min_h_24()
674 .pt(paddings.top)
674 .pt(paddings.top)
@@ -753,24 +753,7 @@ impl RenderOnce for Dialog {
753 "slide-down-shadow",
753 "slide-down-shadow",
754 animation.clone(),
754 animation.clone(),
755 move |this, delta| {
755 move |this, delta| {
756 // This is equivalent to `shadow_xl` with an extra opacity.
756 this.shadow(dialog_elevation.shadow_at(delta))
757 let shadow = vec![
758 BoxShadow {
759 color: hsla(0., 0., 0., 0.1 * delta),
760 offset: point(px(0.), px(20.)),
761 blur_radius: px(25.),
762 spread_radius: px(-5.),
763 inset: false,
764 },
765 BoxShadow {
766 color: hsla(0., 0., 0., 0.1 * delta),
767 offset: point(px(0.), px(8.)),
768 blur_radius: px(10.),
769 spread_radius: px(-6.),
770 inset: false,
771 },
772 ];
773 this.shadow(shadow)
774 },
757 },
775 )
758 )
776 .text_selection_scope(selection_scope),
759 .text_selection_scope(selection_scope),
vendor/gpui-component/src/elevation.rs added +184 −0
@@ -0,0 +1,184 @@
1 //! Fluent 2 dark shadows as Teams paints them. GPUI's shader takes the blur as
2 //! the gaussian's sigma while CSS takes twice that, so every CSS blur is halved.
3
4 use std::collections::HashMap;
5
6 use gpui::{App, BoxShadow, Global, Hsla, Window, WindowId, hsla, point, px};
7
8 use crate::ActiveTheme as _;
9
10 const AMBIENT_INK: f32 = 0.24;
11 const KEY_INK: f32 = 0.28;
12
13 #[derive(Clone, Debug, PartialEq)]
14 pub struct Elevation {
15 pub fill: Hsla,
16 pub hover: Hsla,
17 pub shadow: Vec<BoxShadow>,
18 }
19
20 impl Elevation {
21 pub fn shadow_at(&self, strength: f32) -> Vec<BoxShadow> {
22 let strength = strength.clamp(0., 1.);
23 self.shadow
24 .iter()
25 .cloned()
26 .map(|mut layer| {
27 layer.color = layer.color.alpha(layer.color.a * strength);
28 layer
29 })
30 .collect()
31 }
32 }
33
34 #[derive(Clone, Debug, PartialEq)]
35 pub struct ElevationTokens {
36 pub flyouts: Vec<Elevation>,
37 pub dialog: Elevation,
38 pub toast: Elevation,
39 }
40
41 impl Global for ElevationTokens {}
42
43 fn fluent_shadow(
44 ambient_blur: f32,
45 key_offset: f32,
46 key_blur: f32,
47 ambient_ink: f32,
48 key_ink: f32,
49 ) -> Vec<BoxShadow> {
50 vec![
51 BoxShadow {
52 color: hsla(0., 0., 0., ambient_ink),
53 offset: point(px(0.), px(0.)),
54 blur_radius: px(ambient_blur / 2.),
55 spread_radius: px(0.),
56 inset: false,
57 },
58 BoxShadow {
59 color: hsla(0., 0., 0., key_ink),
60 offset: point(px(0.), px(key_offset)),
61 blur_radius: px(key_blur / 2.),
62 spread_radius: px(0.),
63 inset: false,
64 },
65 ]
66 }
67
68 pub fn shadow8() -> Vec<BoxShadow> {
69 fluent_shadow(2., 4., 8., AMBIENT_INK, KEY_INK)
70 }
71
72 pub fn shadow16() -> Vec<BoxShadow> {
73 fluent_shadow(2., 8., 16., AMBIENT_INK, KEY_INK)
74 }
75
76 pub fn shadow28() -> Vec<BoxShadow> {
77 fluent_shadow(8., 14., 28., AMBIENT_INK, KEY_INK)
78 }
79
80 pub fn shadow64() -> Vec<BoxShadow> {
81 fluent_shadow(8., 32., 64., AMBIENT_INK, KEY_INK)
82 }
83
84 impl ElevationTokens {
85 pub fn from_theme(cx: &App) -> Self {
86 let theme = cx.theme();
87 let flyout = Elevation {
88 fill: theme.popover,
89 hover: theme.sidebar_accent,
90 shadow: shadow16(),
91 };
92 let nested = Elevation {
93 fill: theme.sidebar_accent,
94 hover: theme.secondary_hover,
95 shadow: shadow16(),
96 };
97 Self {
98 flyouts: vec![flyout.clone(), nested],
99 dialog: Elevation {
100 shadow: shadow64(),
101 ..flyout.clone()
102 },
103 toast: Elevation {
104 shadow: shadow8(),
105 ..flyout
106 },
107 }
108 }
109
110 pub fn flyout_at(&self, modal_layers: usize) -> &Elevation {
111 let last = self.flyouts.len().saturating_sub(1);
112 &self.flyouts[modal_layers.min(last)]
113 }
114 }
115
116 #[derive(Default, Clone, Copy, Debug, PartialEq, Eq)]
117 struct ModalLayers {
118 app: usize,
119 framework: usize,
120 }
121
122 impl ModalLayers {
123 fn total(self) -> usize {
124 self.app + self.framework
125 }
126 }
127
128 #[derive(Default)]
129 struct WindowModalLayers(HashMap<WindowId, ModalLayers>);
130
131 impl Global for WindowModalLayers {}
132
133 fn update_layers(window: &Window, cx: &mut App, update: impl FnOnce(&mut ModalLayers)) {
134 let window_id = window.window_handle().window_id();
135 let current = cx
136 .try_global::<WindowModalLayers>()
137 .and_then(|layers| layers.0.get(&window_id).copied())
138 .unwrap_or_default();
139 let mut next = current;
140 update(&mut next);
141 if next == current {
142 return;
143 }
144 let layers = cx.default_global::<WindowModalLayers>();
145 if next == ModalLayers::default() {
146 layers.0.remove(&window_id);
147 } else {
148 layers.0.insert(window_id, next);
149 }
150 }
151
152 pub fn set_app_modal_layers(window: &Window, count: usize, cx: &mut App) {
153 update_layers(window, cx, |layers| layers.app = count);
154 }
155
156 pub(crate) fn set_framework_modal_layers(window: &Window, count: usize, cx: &mut App) {
157 update_layers(window, cx, |layers| layers.framework = count);
158 }
159
160 pub fn modal_layers(window: &Window, cx: &App) -> usize {
161 let window_id = window.window_handle().window_id();
162 cx.try_global::<WindowModalLayers>()
163 .and_then(|layers| layers.0.get(&window_id).copied())
164 .map(ModalLayers::total)
165 .unwrap_or(0)
166 }
167
168 pub fn tokens(cx: &App) -> ElevationTokens {
169 cx.try_global::<ElevationTokens>()
170 .cloned()
171 .unwrap_or_else(|| ElevationTokens::from_theme(cx))
172 }
173
174 pub fn flyout(window: &Window, cx: &App) -> Elevation {
175 tokens(cx).flyout_at(modal_layers(window, cx)).clone()
176 }
177
178 pub fn dialog(cx: &App) -> Elevation {
179 tokens(cx).dialog
180 }
181
182 pub fn toast(cx: &App) -> Elevation {
183 tokens(cx).toast
184 }
@@ -0,0 +1,184 @@
1//! Fluent 2 dark shadows as Teams paints them. GPUI's shader takes the blur as
2//! the gaussian's sigma while CSS takes twice that, so every CSS blur is halved.
3
4use std::collections::HashMap;
5
6use gpui::{App, BoxShadow, Global, Hsla, Window, WindowId, hsla, point, px};
7
8use crate::ActiveTheme as _;
9
10const AMBIENT_INK: f32 = 0.24;
11const KEY_INK: f32 = 0.28;
12
13#[derive(Clone, Debug, PartialEq)]
14pub struct Elevation {
15 pub fill: Hsla,
16 pub hover: Hsla,
17 pub shadow: Vec<BoxShadow>,
18}
19
20impl Elevation {
21 pub fn shadow_at(&self, strength: f32) -> Vec<BoxShadow> {
22 let strength = strength.clamp(0., 1.);
23 self.shadow
24 .iter()
25 .cloned()
26 .map(|mut layer| {
27 layer.color = layer.color.alpha(layer.color.a * strength);
28 layer
29 })
30 .collect()
31 }
32}
33
34#[derive(Clone, Debug, PartialEq)]
35pub struct ElevationTokens {
36 pub flyouts: Vec<Elevation>,
37 pub dialog: Elevation,
38 pub toast: Elevation,
39}
40
41impl Global for ElevationTokens {}
42
43fn fluent_shadow(
44 ambient_blur: f32,
45 key_offset: f32,
46 key_blur: f32,
47 ambient_ink: f32,
48 key_ink: f32,
49) -> Vec<BoxShadow> {
50 vec![
51 BoxShadow {
52 color: hsla(0., 0., 0., ambient_ink),
53 offset: point(px(0.), px(0.)),
54 blur_radius: px(ambient_blur / 2.),
55 spread_radius: px(0.),
56 inset: false,
57 },
58 BoxShadow {
59 color: hsla(0., 0., 0., key_ink),
60 offset: point(px(0.), px(key_offset)),
61 blur_radius: px(key_blur / 2.),
62 spread_radius: px(0.),
63 inset: false,
64 },
65 ]
66}
67
68pub fn shadow8() -> Vec<BoxShadow> {
69 fluent_shadow(2., 4., 8., AMBIENT_INK, KEY_INK)
70}
71
72pub fn shadow16() -> Vec<BoxShadow> {
73 fluent_shadow(2., 8., 16., AMBIENT_INK, KEY_INK)
74}
75
76pub fn shadow28() -> Vec<BoxShadow> {
77 fluent_shadow(8., 14., 28., AMBIENT_INK, KEY_INK)
78}
79
80pub fn shadow64() -> Vec<BoxShadow> {
81 fluent_shadow(8., 32., 64., AMBIENT_INK, KEY_INK)
82}
83
84impl ElevationTokens {
85 pub fn from_theme(cx: &App) -> Self {
86 let theme = cx.theme();
87 let flyout = Elevation {
88 fill: theme.popover,
89 hover: theme.sidebar_accent,
90 shadow: shadow16(),
91 };
92 let nested = Elevation {
93 fill: theme.sidebar_accent,
94 hover: theme.secondary_hover,
95 shadow: shadow16(),
96 };
97 Self {
98 flyouts: vec![flyout.clone(), nested],
99 dialog: Elevation {
100 shadow: shadow64(),
101 ..flyout.clone()
102 },
103 toast: Elevation {
104 shadow: shadow8(),
105 ..flyout
106 },
107 }
108 }
109
110 pub fn flyout_at(&self, modal_layers: usize) -> &Elevation {
111 let last = self.flyouts.len().saturating_sub(1);
112 &self.flyouts[modal_layers.min(last)]
113 }
114}
115
116#[derive(Default, Clone, Copy, Debug, PartialEq, Eq)]
117struct ModalLayers {
118 app: usize,
119 framework: usize,
120}
121
122impl ModalLayers {
123 fn total(self) -> usize {
124 self.app + self.framework
125 }
126}
127
128#[derive(Default)]
129struct WindowModalLayers(HashMap<WindowId, ModalLayers>);
130
131impl Global for WindowModalLayers {}
132
133fn update_layers(window: &Window, cx: &mut App, update: impl FnOnce(&mut ModalLayers)) {
134 let window_id = window.window_handle().window_id();
135 let current = cx
136 .try_global::<WindowModalLayers>()
137 .and_then(|layers| layers.0.get(&window_id).copied())
138 .unwrap_or_default();
139 let mut next = current;
140 update(&mut next);
141 if next == current {
142 return;
143 }
144 let layers = cx.default_global::<WindowModalLayers>();
145 if next == ModalLayers::default() {
146 layers.0.remove(&window_id);
147 } else {
148 layers.0.insert(window_id, next);
149 }
150}
151
152pub fn set_app_modal_layers(window: &Window, count: usize, cx: &mut App) {
153 update_layers(window, cx, |layers| layers.app = count);
154}
155
156pub(crate) fn set_framework_modal_layers(window: &Window, count: usize, cx: &mut App) {
157 update_layers(window, cx, |layers| layers.framework = count);
158}
159
160pub fn modal_layers(window: &Window, cx: &App) -> usize {
161 let window_id = window.window_handle().window_id();
162 cx.try_global::<WindowModalLayers>()
163 .and_then(|layers| layers.0.get(&window_id).copied())
164 .map(ModalLayers::total)
165 .unwrap_or(0)
166}
167
168pub fn tokens(cx: &App) -> ElevationTokens {
169 cx.try_global::<ElevationTokens>()
170 .cloned()
171 .unwrap_or_else(|| ElevationTokens::from_theme(cx))
172}
173
174pub fn flyout(window: &Window, cx: &App) -> Elevation {
175 tokens(cx).flyout_at(modal_layers(window, cx)).clone()
176}
177
178pub fn dialog(cx: &App) -> Elevation {
179 tokens(cx).dialog
180}
181
182pub fn toast(cx: &App) -> Elevation {
183 tokens(cx).toast
184}
vendor/gpui-component/src/input/popovers/code_action_menu.rs +1 −1
@@ -314,7 +314,7 @@ impl Render for CodeActionMenu {
314 314 let max_width = MAX_MENU_WIDTH.min(window.bounds().size.width - pos.x);
315 315
316 316 deferred(
317 editor_popover("code-action-menu", cx)
317 editor_popover("code-action-menu", window, cx)
318 318 .absolute()
319 319 .left(pos.x)
320 320 .top(pos.y)
@@ -314,7 +314,7 @@ impl Render for CodeActionMenu {
314 let max_width = MAX_MENU_WIDTH.min(window.bounds().size.width - pos.x);
314 let max_width = MAX_MENU_WIDTH.min(window.bounds().size.width - pos.x);
315
315
316 deferred(
316 deferred(
317 editor_popover("code-action-menu", cx)
317 editor_popover("code-action-menu", window, cx)
318 .absolute()
318 .absolute()
319 .left(pos.x)
319 .left(pos.x)
320 .top(pos.y)
320 .top(pos.y)
vendor/gpui-component/src/input/popovers/completion_menu.rs +2 −2
@@ -403,7 +403,7 @@ impl Render for CompletionMenu {
403 403 .items_start()
404 404 .when(vertical_layout, |this| this.flex_col())
405 405 .child(
406 editor_popover("completion-menu", cx)
406 editor_popover("completion-menu", window, cx)
407 407 .max_w(max_width)
408 408 .min_w(px(120.))
409 409 .child(List::new(&self.list).max_h(MAX_MENU_HEIGHT)),
@@ -419,7 +419,7 @@ impl Render for CompletionMenu {
419 419
420 420 this.child(
421 421 div().child(
422 editor_popover("completion-menu", cx)
422 editor_popover("completion-menu", window, cx)
423 423 .w(configured_max)
424 424 .px_2()
425 425 .child(render_markdown("doc", doc, window, cx)),
@@ -403,7 +403,7 @@ impl Render for CompletionMenu {
403 .items_start()
403 .items_start()
404 .when(vertical_layout, |this| this.flex_col())
404 .when(vertical_layout, |this| this.flex_col())
405 .child(
405 .child(
406 editor_popover("completion-menu", cx)
406 editor_popover("completion-menu", window, cx)
407 .max_w(max_width)
407 .max_w(max_width)
408 .min_w(px(120.))
408 .min_w(px(120.))
409 .child(List::new(&self.list).max_h(MAX_MENU_HEIGHT)),
409 .child(List::new(&self.list).max_h(MAX_MENU_HEIGHT)),
@@ -419,7 +419,7 @@ impl Render for CompletionMenu {
419
419
420 this.child(
420 this.child(
421 div().child(
421 div().child(
422 editor_popover("completion-menu", cx)
422 editor_popover("completion-menu", window, cx)
423 .w(configured_max)
423 .w(configured_max)
424 .px_2()
424 .px_2()
425 .child(render_markdown("doc", doc, window, cx)),
425 .child(render_markdown("doc", doc, window, cx)),
vendor/gpui-component/src/input/popovers/hover_popover.rs +1 −2
@@ -166,8 +166,7 @@ impl Element for Popover {
166 166 .occlude()
167 167 .p_1()
168 168 .text_xs()
169 .popover_style(cx)
170 .shadow_md()
169 .popover_style(window, cx)
171 170 .max_w(max_width)
172 171 .max_h(max_height)
173 172 .overflow_y_scroll()
@@ -166,8 +166,7 @@ impl Element for Popover {
166 .occlude()
166 .occlude()
167 .p_1()
167 .p_1()
168 .text_xs()
168 .text_xs()
169 .popover_style(cx)
169 .popover_style(window, cx)
170 .shadow_md()
171 .max_w(max_width)
170 .max_w(max_width)
172 .max_h(max_height)
171 .max_h(max_height)
173 .overflow_y_scroll()
172 .overflow_y_scroll()
vendor/gpui-component/src/input/popovers/mod.rs +2 −3
@@ -43,13 +43,12 @@ pub(super) fn render_markdown(
43 43 .selectable(true)
44 44 }
45 45
46 pub(super) fn editor_popover(id: impl Into<ElementId>, cx: &App) -> Stateful<Div> {
46 pub(super) fn editor_popover(id: impl Into<ElementId>, window: &Window, cx: &App) -> Stateful<Div> {
47 47 div()
48 48 .id(id)
49 49 .flex_none()
50 50 .occlude()
51 .popover_style(cx)
52 .shadow_md()
51 .popover_style(window, cx)
53 52 .text_xs()
54 53 .p_1()
55 54 }
@@ -43,13 +43,12 @@ pub(super) fn render_markdown(
43 .selectable(true)
43 .selectable(true)
44}
44}
45
45
46pub(super) fn editor_popover(id: impl Into<ElementId>, cx: &App) -> Stateful<Div> {
46pub(super) fn editor_popover(id: impl Into<ElementId>, window: &Window, cx: &App) -> Stateful<Div> {
47 div()
47 div()
48 .id(id)
48 .id(id)
49 .flex_none()
49 .flex_none()
50 .occlude()
50 .occlude()
51 .popover_style(cx)
51 .popover_style(window, cx)
52 .shadow_md()
53 .text_xs()
52 .text_xs()
54 .p_1()
53 .p_1()
55}
54}
vendor/gpui-component/src/lib.rs +1 −0
@@ -42,6 +42,7 @@ pub mod command;
42 42 pub mod description_list;
43 43 pub mod dialog;
44 44 pub mod dock;
45 pub mod elevation;
45 46 pub mod empty;
46 47 pub mod form;
47 48 pub mod group_box;
@@ -42,6 +42,7 @@ pub mod command;
42pub mod description_list;
42pub mod description_list;
43pub mod dialog;
43pub mod dialog;
44pub mod dock;
44pub mod dock;
45pub mod elevation;
45pub mod empty;
46pub mod empty;
46pub mod form;
47pub mod form;
47pub mod group_box;
48pub mod group_box;
vendor/gpui-component/src/menu/menu_item.rs +4 −3
@@ -90,7 +90,8 @@ impl ParentElement for MenuItemElement {
90 90 }
91 91
92 92 impl RenderOnce for MenuItemElement {
93 fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement {
93 fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement {
94 let highlight = crate::elevation::flyout(window, cx).hover;
94 95 h_flex()
95 96 .id(self.id)
96 97 .test_support()
@@ -114,11 +115,11 @@ impl RenderOnce for MenuItemElement {
114 115 // element before registering its group, and that fallback keeps
115 116 // the pointer's item lit after a key moves the highlight away.
116 117 this.hover(|this| {
117 this.bg(cx.theme().tokens.sidebar_accent)
118 this.bg(highlight)
118 119 .text_color(cx.theme().sidebar_accent_foreground)
119 120 })
120 121 .when(self.selected, |this| {
121 this.bg(cx.theme().tokens.sidebar_accent)
122 this.bg(highlight)
122 123 .text_color(cx.theme().sidebar_accent_foreground)
123 124 })
124 125 .when_some(self.on_click, |this, on_click| {
@@ -90,7 +90,8 @@ impl ParentElement for MenuItemElement {
90}
90}
91
91
92impl RenderOnce for MenuItemElement {
92impl RenderOnce for MenuItemElement {
93 fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement {
93 fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement {
94 let highlight = crate::elevation::flyout(window, cx).hover;
94 h_flex()
95 h_flex()
95 .id(self.id)
96 .id(self.id)
96 .test_support()
97 .test_support()
@@ -114,11 +115,11 @@ impl RenderOnce for MenuItemElement {
114 // element before registering its group, and that fallback keeps
115 // element before registering its group, and that fallback keeps
115 // the pointer's item lit after a key moves the highlight away.
116 // the pointer's item lit after a key moves the highlight away.
116 this.hover(|this| {
117 this.hover(|this| {
117 this.bg(cx.theme().tokens.sidebar_accent)
118 this.bg(highlight)
118 .text_color(cx.theme().sidebar_accent_foreground)
119 .text_color(cx.theme().sidebar_accent_foreground)
119 })
120 })
120 .when(self.selected, |this| {
121 .when(self.selected, |this| {
121 this.bg(cx.theme().tokens.sidebar_accent)
122 this.bg(highlight)
122 .text_color(cx.theme().sidebar_accent_foreground)
123 .text_color(cx.theme().sidebar_accent_foreground)
123 })
124 })
124 .when_some(self.on_click, |this, on_click| {
125 .when_some(self.on_click, |this, on_click| {
vendor/gpui-component/src/menu/popup_menu.rs +1 −1
@@ -1478,7 +1478,7 @@ impl Render for PopupMenu {
1478 1478 .on_action(cx.listener(Self::confirm))
1479 1479 .on_action(cx.listener(Self::dismiss))
1480 1480 .on_mouse_down_out(cx.listener(Self::on_mouse_down_out))
1481 .popover_style(cx)
1481 .popover_style(window, cx)
1482 1482 .text_color(cx.theme().popover_foreground)
1483 1483 .relative()
1484 1484 .occlude()
@@ -1478,7 +1478,7 @@ impl Render for PopupMenu {
1478 .on_action(cx.listener(Self::confirm))
1478 .on_action(cx.listener(Self::confirm))
1479 .on_action(cx.listener(Self::dismiss))
1479 .on_action(cx.listener(Self::dismiss))
1480 .on_mouse_down_out(cx.listener(Self::on_mouse_down_out))
1480 .on_mouse_down_out(cx.listener(Self::on_mouse_down_out))
1481 .popover_style(cx)
1481 .popover_style(window, cx)
1482 .text_color(cx.theme().popover_foreground)
1482 .text_color(cx.theme().popover_foreground)
1483 .relative()
1483 .relative()
1484 .occlude()
1484 .occlude()
vendor/gpui-component/src/notification.rs +8 −5
@@ -23,7 +23,6 @@ use crate::{
23 23 ActiveTheme as _, Edges, Icon, IconName, Sizable as _, StyledExt, TITLE_BAR_HEIGHT,
24 24 animation::cubic_bezier,
25 25 button::{Button, ButtonVariants as _},
26 styled::toast_shadow,
27 26 v_flex,
28 27 };
29 28
@@ -418,6 +417,8 @@ impl Render for Notification {
418 417 };
419 418 let has_icon = icon.is_some();
420 419 let placement = self.placement.unwrap_or(cx.theme().notification.placement);
420 let toast_elevation = crate::elevation::toast(cx);
421 let resting_shadow = toast_elevation.shadow.clone();
421 422
422 423 BaseToast::new("notification")
423 424 .transition_status(transition_status)
@@ -428,9 +429,9 @@ impl Render for Notification {
428 429 .w_full()
429 430 .border_1()
430 431 .border_color(cx.theme().border)
431 .bg(cx.theme().tokens.popover)
432 .bg(toast_elevation.fill)
432 433 .rounded(cx.theme().radius_lg)
433 .shadow(toast_shadow(1.))
434 .shadow(resting_shadow)
434 435 .py_3p5()
435 436 .px_4()
436 437 .gap_3()
@@ -492,7 +493,9 @@ impl Render for Notification {
492 493 move |this, delta| {
493 494 if closing {
494 495 let opacity = 1. - delta;
495 let that = this.opacity(opacity).shadow(toast_shadow(opacity.powi(3)));
496 let that = this
497 .opacity(opacity)
498 .shadow(toast_elevation.shadow_at(opacity.powi(3)));
496 499 let y_offset = match placement {
497 500 Anchor::TopLeft | Anchor::TopRight | Anchor::TopCenter => {
498 501 -delta * NOTIFICATION_TRANSITION_OFFSET
@@ -525,7 +528,7 @@ impl Render for Notification {
525 528 // threshold, which popped.
526 529 this.top(px(0.) + y_offset)
527 530 .opacity(opacity)
528 .shadow(toast_shadow(opacity.powi(3)))
531 .shadow(toast_elevation.shadow_at(opacity.powi(3)))
529 532 }
530 533 },
531 534 )
@@ -23,7 +23,6 @@ use crate::{
23 ActiveTheme as _, Edges, Icon, IconName, Sizable as _, StyledExt, TITLE_BAR_HEIGHT,
23 ActiveTheme as _, Edges, Icon, IconName, Sizable as _, StyledExt, TITLE_BAR_HEIGHT,
24 animation::cubic_bezier,
24 animation::cubic_bezier,
25 button::{Button, ButtonVariants as _},
25 button::{Button, ButtonVariants as _},
26 styled::toast_shadow,
27 v_flex,
26 v_flex,
28};
27};
29
28
@@ -418,6 +417,8 @@ impl Render for Notification {
418 };
417 };
419 let has_icon = icon.is_some();
418 let has_icon = icon.is_some();
420 let placement = self.placement.unwrap_or(cx.theme().notification.placement);
419 let placement = self.placement.unwrap_or(cx.theme().notification.placement);
420 let toast_elevation = crate::elevation::toast(cx);
421 let resting_shadow = toast_elevation.shadow.clone();
421
422
422 BaseToast::new("notification")
423 BaseToast::new("notification")
423 .transition_status(transition_status)
424 .transition_status(transition_status)
@@ -428,9 +429,9 @@ impl Render for Notification {
428 .w_full()
429 .w_full()
429 .border_1()
430 .border_1()
430 .border_color(cx.theme().border)
431 .border_color(cx.theme().border)
431 .bg(cx.theme().tokens.popover)
432 .bg(toast_elevation.fill)
432 .rounded(cx.theme().radius_lg)
433 .rounded(cx.theme().radius_lg)
433 .shadow(toast_shadow(1.))
434 .shadow(resting_shadow)
434 .py_3p5()
435 .py_3p5()
435 .px_4()
436 .px_4()
436 .gap_3()
437 .gap_3()
@@ -492,7 +493,9 @@ impl Render for Notification {
492 move |this, delta| {
493 move |this, delta| {
493 if closing {
494 if closing {
494 let opacity = 1. - delta;
495 let opacity = 1. - delta;
495 let that = this.opacity(opacity).shadow(toast_shadow(opacity.powi(3)));
496 let that = this
497 .opacity(opacity)
498 .shadow(toast_elevation.shadow_at(opacity.powi(3)));
496 let y_offset = match placement {
499 let y_offset = match placement {
497 Anchor::TopLeft | Anchor::TopRight | Anchor::TopCenter => {
500 Anchor::TopLeft | Anchor::TopRight | Anchor::TopCenter => {
498 -delta * NOTIFICATION_TRANSITION_OFFSET
501 -delta * NOTIFICATION_TRANSITION_OFFSET
@@ -525,7 +528,7 @@ impl Render for Notification {
525 // threshold, which popped.
528 // threshold, which popped.
526 this.top(px(0.) + y_offset)
529 this.top(px(0.) + y_offset)
527 .opacity(opacity)
530 .opacity(opacity)
528 .shadow(toast_shadow(opacity.powi(3)))
531 .shadow(toast_elevation.shadow_at(opacity.powi(3)))
529 }
532 }
530 },
533 },
531 )
534 )
vendor/gpui-component/src/plot/tooltip.rs +1 −1
@@ -587,7 +587,7 @@ impl RenderOnce for Tooltip {
587 587 this.absolute()
588 588 .opacity(progress)
589 589 .when(min_w_unset, |c| c.min_w(px(150.)))
590 .popover_style(cx)
590 .popover_style(window, cx)
591 591 .p_2()
592 592 .map(|c| {
593 593 if cursor.x < within.width * 0.5 {
@@ -587,7 +587,7 @@ impl RenderOnce for Tooltip {
587 this.absolute()
587 this.absolute()
588 .opacity(progress)
588 .opacity(progress)
589 .when(min_w_unset, |c| c.min_w(px(150.)))
589 .when(min_w_unset, |c| c.min_w(px(150.)))
590 .popover_style(cx)
590 .popover_style(window, cx)
591 .p_2()
591 .p_2()
592 .map(|c| {
592 .map(|c| {
593 if cursor.x < within.width * 0.5 {
593 if cursor.x < within.width * 0.5 {
vendor/gpui-component/src/popover.rs +4 −4
@@ -61,7 +61,7 @@ fn dropdown_positioner(bounds: Bounds<Pixels>) -> gpui_base::Positioner {
61 61 /// shadow, and mid-fade the shadow shows straight through the panel as a dark
62 62 /// slab. Ramping the ink by the cube of the fade keeps it out of sight until the
63 63 /// panel is opaque enough to cover it, and still lands on the resting shadow
64 /// [`popover_shadow`] gives every other popup.
64 /// [`crate::elevation::flyout`] gives every other popup.
65 65 ///
66 66 /// # Departures from shadcn
67 67 ///
@@ -292,14 +292,14 @@ impl Popover {
292 292 pub(crate) fn render_popover_content(
293 293 anchor: Anchor,
294 294 appearance: bool,
295 _: &mut Window,
295 window: &mut Window,
296 296 cx: &mut App,
297 297 ) -> Stateful<Div> {
298 298 v_flex()
299 299 .id("content")
300 300 .occlude()
301 301 .tab_group()
302 .when(appearance, |this| this.popover_style(cx).p_3())
302 .when(appearance, |this| this.popover_style(window, cx).p_3())
303 303 .map(|this| match anchor {
304 304 Anchor::TopLeft | Anchor::TopCenter | Anchor::TopRight => this.top_1(),
305 305 Anchor::BottomLeft | Anchor::BottomCenter | Anchor::BottomRight => this.bottom_1(),
@@ -346,7 +346,7 @@ impl RenderOnce for Popover {
346 346 .id("content")
347 347 .occlude()
348 348 .tab_group()
349 .when(appearance, |this| this.popover_style(cx).p_3())
349 .when(appearance, |this| this.popover_style(window, cx).p_3())
350 350 .when_some(content, |this, content| {
351 351 this.child((content)(state, window, cx))
352 352 })
@@ -61,7 +61,7 @@ fn dropdown_positioner(bounds: Bounds<Pixels>) -> gpui_base::Positioner {
61/// shadow, and mid-fade the shadow shows straight through the panel as a dark
61/// shadow, and mid-fade the shadow shows straight through the panel as a dark
62/// slab. Ramping the ink by the cube of the fade keeps it out of sight until the
62/// slab. Ramping the ink by the cube of the fade keeps it out of sight until the
63/// panel is opaque enough to cover it, and still lands on the resting shadow
63/// panel is opaque enough to cover it, and still lands on the resting shadow
64/// [`popover_shadow`] gives every other popup.
64/// [`crate::elevation::flyout`] gives every other popup.
65///
65///
66/// # Departures from shadcn
66/// # Departures from shadcn
67///
67///
@@ -292,14 +292,14 @@ impl Popover {
292 pub(crate) fn render_popover_content(
292 pub(crate) fn render_popover_content(
293 anchor: Anchor,
293 anchor: Anchor,
294 appearance: bool,
294 appearance: bool,
295 _: &mut Window,
295 window: &mut Window,
296 cx: &mut App,
296 cx: &mut App,
297 ) -> Stateful<Div> {
297 ) -> Stateful<Div> {
298 v_flex()
298 v_flex()
299 .id("content")
299 .id("content")
300 .occlude()
300 .occlude()
301 .tab_group()
301 .tab_group()
302 .when(appearance, |this| this.popover_style(cx).p_3())
302 .when(appearance, |this| this.popover_style(window, cx).p_3())
303 .map(|this| match anchor {
303 .map(|this| match anchor {
304 Anchor::TopLeft | Anchor::TopCenter | Anchor::TopRight => this.top_1(),
304 Anchor::TopLeft | Anchor::TopCenter | Anchor::TopRight => this.top_1(),
305 Anchor::BottomLeft | Anchor::BottomCenter | Anchor::BottomRight => this.bottom_1(),
305 Anchor::BottomLeft | Anchor::BottomCenter | Anchor::BottomRight => this.bottom_1(),
@@ -346,7 +346,7 @@ impl RenderOnce for Popover {
346 .id("content")
346 .id("content")
347 .occlude()
347 .occlude()
348 .tab_group()
348 .tab_group()
349 .when(appearance, |this| this.popover_style(cx).p_3())
349 .when(appearance, |this| this.popover_style(window, cx).p_3())
350 .when_some(content, |this, content| {
350 .when_some(content, |this, content| {
351 this.child((content)(state, window, cx))
351 this.child((content)(state, window, cx))
352 })
352 })
vendor/gpui-component/src/root.rs +1 −0
@@ -184,6 +184,7 @@ impl WindowState {
184 184 cx: &mut App,
185 185 ) -> Option<impl IntoElement + use<>> {
186 186 let active_dialogs = root.read(cx).active_dialogs.clone();
187 crate::elevation::set_framework_modal_layers(window, active_dialogs.len(), cx);
187 188
188 189 if active_dialogs.is_empty() {
189 190 return None;
@@ -184,6 +184,7 @@ impl WindowState {
184 cx: &mut App,
184 cx: &mut App,
185 ) -> Option<impl IntoElement + use<>> {
185 ) -> Option<impl IntoElement + use<>> {
186 let active_dialogs = root.read(cx).active_dialogs.clone();
186 let active_dialogs = root.read(cx).active_dialogs.clone();
187 crate::elevation::set_framework_modal_layers(window, active_dialogs.len(), cx);
187
188
188 if active_dialogs.is_empty() {
189 if active_dialogs.is_empty() {
189 return None;
190 return None;
vendor/gpui-component/src/select.rs +1 −1
@@ -616,7 +616,7 @@ where
616 616 Length::Auto => this.w(bounds.size.width),
617 617 Length::Definite(w) => this.w(w),
618 618 })
619 .popover_style(cx)
619 .popover_style(window, cx)
620 620 .child(
621 621 List::new(&self.state.list)
622 622 .when_some(
@@ -616,7 +616,7 @@ where
616 Length::Auto => this.w(bounds.size.width),
616 Length::Auto => this.w(bounds.size.width),
617 Length::Definite(w) => this.w(w),
617 Length::Definite(w) => this.w(w),
618 })
618 })
619 .popover_style(cx)
619 .popover_style(window, cx)
620 .child(
620 .child(
621 List::new(&self.state.list)
621 List::new(&self.state.list)
622 .when_some(
622 .when_some(
vendor/gpui-component/src/styled.rs +9 −64
@@ -37,64 +37,6 @@ pub(crate) fn popover_ring(cx: &App) -> Hsla {
37 37 cx.theme().foreground.alpha(POPOVER_RING_INK)
38 38 }
39 39
40 /// shadcn/ui's popup surface shadow — a hairline `ring` plus `shadow-md` — at
41 /// `strength` of its full ink.
42 ///
43 /// Callers animating a surface in pass a rising `strength`; a resting surface
44 /// passes `1.0`.
45 ///
46 /// The two blurred layers use Tailwind's radii **halved**, which is the
47 /// conversion CSS requires and not a taste adjustment. CSS defines a box
48 /// shadow's blur radius as twice the gaussian's standard deviation, while GPUI's
49 /// shader takes the field as the deviation itself (`gaussian(y, sigma)`).
50 /// Copying Tailwind's `6px` and `4px` across therefore spreads the shadow over
51 /// twice the distance, which is why [`Styled::shadow_md`] reads as a wide grey
52 /// haze next to a browser's compact one.
53 ///
54 /// Measured against shadcn's own render, this lands within a luminance step of
55 /// it the whole way down the falloff.
56 ///
57 /// The ring is taken as a colour rather than read from the theme here so that an
58 /// animation can hold it across frames, where no `App` is in hand.
59 #[allow(dead_code)]
60 pub(crate) fn popover_shadow(ring: Hsla, strength: f32) -> Vec<BoxShadow> {
61 let strength = strength.clamp(0., 1.);
62 let ink = hsla(0., 0., 0., SURFACE_SHADOW_INK * strength);
63 vec![
64 // The ring, sitting in the 1px band outside the surface. No blur, so it
65 // takes the shader's crisp path rather than the gaussian one.
66 BoxShadow::new(px(0.), px(0.), ring.alpha(ring.a * strength))
67 .blur_radius(px(0.))
68 .spread_radius(px(1.)),
69 BoxShadow::new(px(0.), px(4.), ink)
70 .blur_radius(px(3.))
71 .spread_radius(px(-1.)),
72 BoxShadow::new(px(0.), px(2.), ink)
73 .blur_radius(px(2.))
74 .spread_radius(px(-2.)),
75 ]
76 }
77
78 /// shadcn/ui's `shadow-lg`, the elevation it lifts a toast to, at `strength` of
79 /// its full ink.
80 ///
81 /// A toast sits higher than a popover and is built differently: shadcn gives it
82 /// a real 1px border rather than the translucent ring it puts on a popup, so
83 /// there is no ring layer here. Its corner radius is left to the caller.
84 ///
85 /// The radii are Tailwind's halved, for the reason [`popover_shadow`] explains.
86 pub(crate) fn toast_shadow(strength: f32) -> Vec<BoxShadow> {
87 let ink = hsla(0., 0., 0., SURFACE_SHADOW_INK * strength.clamp(0., 1.));
88 vec![
89 BoxShadow::new(px(0.), px(10.), ink)
90 .blur_radius(px(7.5))
91 .spread_radius(px(-3.)),
92 BoxShadow::new(px(0.), px(4.), ink)
93 .blur_radius(px(3.))
94 .spread_radius(px(-4.)),
95 ]
96 }
97
98 40 /// shadcn/ui's `shadow-sm`, the elevation it spends on a control raised out of
99 41 /// the container it sits in — the active pill of a segmented tab bar — at full
100 42 /// ink.
@@ -105,7 +47,7 @@ pub(crate) fn toast_shadow(strength: f32) -> Vec<BoxShadow> {
105 47 /// wide one, and a wide one would read as grime against the trough wall rather
106 48 /// than as lift.
107 49 ///
108 /// The radii are Tailwind's halved, for the reason [`popover_shadow`] explains:
50 /// The radii are Tailwind's halved, for the reason [`crate::elevation`] explains:
109 51 /// CSS defines a box shadow's blur radius as twice the gaussian's standard
110 52 /// deviation, while GPUI's shader takes the field as the deviation itself
111 53 /// (`gaussian(y, sigma)`). Copying Tailwind's `3px` and `2px` across therefore
@@ -148,12 +90,13 @@ pub trait ThemeStyled: Styled + Sized {
148 90 where
149 91 Self: ParentElement;
150 92
151 /// Give this element the surface, edge, shadow and radius of a popover.
93 /// Give this element the surface, shadow and radius of a flyout at the
94 /// elevation level `window` currently opens flyouts at.
152 95 ///
153 96 /// This is the one surface every popup shares — Popover, PopupMenu, Select,
154 97 /// Combobox, DatePicker and the editor's hover popovers — so they cannot
155 /// drift apart. See [`popover_shadow`] for what the shadow is modelled on.
156 fn popover_style(self, cx: &App) -> Self;
98 /// drift apart. See [`crate::elevation`].
99 fn popover_style(self, window: &Window, cx: &App) -> Self;
157 100
158 101 /// Round this element as far as its size allows — a circle if it is square,
159 102 /// a pill if it is not — unless the theme squares its corners.
@@ -184,9 +127,11 @@ impl<T: Styled + Sized> ThemeStyled for T {
184 127 focus_style(self, FocusLine::Edge, window, cx)
185 128 }
186 129
187 fn popover_style(self, cx: &App) -> Self {
130 fn popover_style(self, window: &Window, cx: &App) -> Self {
188 131 let theme = cx.theme();
189 self.bg(theme.popover)
132 let elevation = crate::elevation::flyout(window, cx);
133 self.bg(elevation.fill)
134 .shadow(elevation.shadow)
190 135 .text_color(theme.popover_foreground)
191 136 .rounded(theme.radius_lg)
192 137 }
@@ -37,64 +37,6 @@ pub(crate) fn popover_ring(cx: &App) -> Hsla {
37 cx.theme().foreground.alpha(POPOVER_RING_INK)
37 cx.theme().foreground.alpha(POPOVER_RING_INK)
38}
38}
39
39
40/// shadcn/ui's popup surface shadow — a hairline `ring` plus `shadow-md` — at
41/// `strength` of its full ink.
42///
43/// Callers animating a surface in pass a rising `strength`; a resting surface
44/// passes `1.0`.
45///
46/// The two blurred layers use Tailwind's radii **halved**, which is the
47/// conversion CSS requires and not a taste adjustment. CSS defines a box
48/// shadow's blur radius as twice the gaussian's standard deviation, while GPUI's
49/// shader takes the field as the deviation itself (`gaussian(y, sigma)`).
50/// Copying Tailwind's `6px` and `4px` across therefore spreads the shadow over
51/// twice the distance, which is why [`Styled::shadow_md`] reads as a wide grey
52/// haze next to a browser's compact one.
53///
54/// Measured against shadcn's own render, this lands within a luminance step of
55/// it the whole way down the falloff.
56///
57/// The ring is taken as a colour rather than read from the theme here so that an
58/// animation can hold it across frames, where no `App` is in hand.
59#[allow(dead_code)]
60pub(crate) fn popover_shadow(ring: Hsla, strength: f32) -> Vec<BoxShadow> {
61 let strength = strength.clamp(0., 1.);
62 let ink = hsla(0., 0., 0., SURFACE_SHADOW_INK * strength);
63 vec![
64 // The ring, sitting in the 1px band outside the surface. No blur, so it
65 // takes the shader's crisp path rather than the gaussian one.
66 BoxShadow::new(px(0.), px(0.), ring.alpha(ring.a * strength))
67 .blur_radius(px(0.))
68 .spread_radius(px(1.)),
69 BoxShadow::new(px(0.), px(4.), ink)
70 .blur_radius(px(3.))
71 .spread_radius(px(-1.)),
72 BoxShadow::new(px(0.), px(2.), ink)
73 .blur_radius(px(2.))
74 .spread_radius(px(-2.)),
75 ]
76}
77
78/// shadcn/ui's `shadow-lg`, the elevation it lifts a toast to, at `strength` of
79/// its full ink.
80///
81/// A toast sits higher than a popover and is built differently: shadcn gives it
82/// a real 1px border rather than the translucent ring it puts on a popup, so
83/// there is no ring layer here. Its corner radius is left to the caller.
84///
85/// The radii are Tailwind's halved, for the reason [`popover_shadow`] explains.
86pub(crate) fn toast_shadow(strength: f32) -> Vec<BoxShadow> {
87 let ink = hsla(0., 0., 0., SURFACE_SHADOW_INK * strength.clamp(0., 1.));
88 vec![
89 BoxShadow::new(px(0.), px(10.), ink)
90 .blur_radius(px(7.5))
91 .spread_radius(px(-3.)),
92 BoxShadow::new(px(0.), px(4.), ink)
93 .blur_radius(px(3.))
94 .spread_radius(px(-4.)),
95 ]
96}
97
98/// shadcn/ui's `shadow-sm`, the elevation it spends on a control raised out of
40/// shadcn/ui's `shadow-sm`, the elevation it spends on a control raised out of
99/// the container it sits in — the active pill of a segmented tab bar — at full
41/// the container it sits in — the active pill of a segmented tab bar — at full
100/// ink.
42/// ink.
@@ -105,7 +47,7 @@ pub(crate) fn toast_shadow(strength: f32) -> Vec<BoxShadow> {
105/// wide one, and a wide one would read as grime against the trough wall rather
47/// wide one, and a wide one would read as grime against the trough wall rather
106/// than as lift.
48/// than as lift.
107///
49///
108/// The radii are Tailwind's halved, for the reason [`popover_shadow`] explains:
50/// The radii are Tailwind's halved, for the reason [`crate::elevation`] explains:
109/// CSS defines a box shadow's blur radius as twice the gaussian's standard
51/// CSS defines a box shadow's blur radius as twice the gaussian's standard
110/// deviation, while GPUI's shader takes the field as the deviation itself
52/// deviation, while GPUI's shader takes the field as the deviation itself
111/// (`gaussian(y, sigma)`). Copying Tailwind's `3px` and `2px` across therefore
53/// (`gaussian(y, sigma)`). Copying Tailwind's `3px` and `2px` across therefore
@@ -148,12 +90,13 @@ pub trait ThemeStyled: Styled + Sized {
148 where
90 where
149 Self: ParentElement;
91 Self: ParentElement;
150
92
151 /// Give this element the surface, edge, shadow and radius of a popover.
93 /// Give this element the surface, shadow and radius of a flyout at the
94 /// elevation level `window` currently opens flyouts at.
152 ///
95 ///
153 /// This is the one surface every popup shares — Popover, PopupMenu, Select,
96 /// This is the one surface every popup shares — Popover, PopupMenu, Select,
154 /// Combobox, DatePicker and the editor's hover popovers — so they cannot
97 /// Combobox, DatePicker and the editor's hover popovers — so they cannot
155 /// drift apart. See [`popover_shadow`] for what the shadow is modelled on.
98 /// drift apart. See [`crate::elevation`].
156 fn popover_style(self, cx: &App) -> Self;
99 fn popover_style(self, window: &Window, cx: &App) -> Self;
157
100
158 /// Round this element as far as its size allows — a circle if it is square,
101 /// Round this element as far as its size allows — a circle if it is square,
159 /// a pill if it is not — unless the theme squares its corners.
102 /// a pill if it is not — unless the theme squares its corners.
@@ -184,9 +127,11 @@ impl<T: Styled + Sized> ThemeStyled for T {
184 focus_style(self, FocusLine::Edge, window, cx)
127 focus_style(self, FocusLine::Edge, window, cx)
185 }
128 }
186
129
187 fn popover_style(self, cx: &App) -> Self {
130 fn popover_style(self, window: &Window, cx: &App) -> Self {
188 let theme = cx.theme();
131 let theme = cx.theme();
189 self.bg(theme.popover)
132 let elevation = crate::elevation::flyout(window, cx);
133 self.bg(elevation.fill)
134 .shadow(elevation.shadow)
190 .text_color(theme.popover_foreground)
135 .text_color(theme.popover_foreground)
191 .rounded(theme.radius_lg)
136 .rounded(theme.radius_lg)
192 }
137 }
vendor/gpui-component/src/time/date_picker.rs +1 −1
@@ -792,7 +792,7 @@ impl RenderOnce for DatePicker {
792 792 div()
793 793 .occlude()
794 794 .p_3()
795 .popover_style(cx)
795 .popover_style(window, cx)
796 796 .on_mouse_up_out(
797 797 MouseButton::Left,
798 798 window.listener_for(&self.state, |view, _, window, cx| {
@@ -792,7 +792,7 @@ impl RenderOnce for DatePicker {
792 div()
792 div()
793 .occlude()
793 .occlude()
794 .p_3()
794 .p_3()
795 .popover_style(cx)
795 .popover_style(window, cx)
796 .on_mouse_up_out(
796 .on_mouse_up_out(
797 MouseButton::Left,
797 MouseButton::Left,
798 window.listener_for(&self.state, |view, _, window, cx| {
798 window.listener_for(&self.state, |view, _, window, cx| {
vendor/gpui-component/src/tooltip.rs +3 −2
@@ -91,6 +91,7 @@ impl Styled for Tooltip {
91 91 }
92 92 impl Render for Tooltip {
93 93 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
94 let flyout_fill = crate::elevation::flyout(window, cx).fill;
94 95 let key_binding = if let Some(key_binding) = &self.key_binding {
95 96 Some(key_binding.clone())
96 97 } else {
@@ -111,9 +112,9 @@ impl Render for Tooltip {
111 112 .h_flex()
112 113 .font_family(cx.theme().font_family.clone())
113 114 .m_3()
114 .bg(cx.theme().tokens.popover)
115 .bg(flyout_fill)
116 .shadow(crate::elevation::shadow8())
115 117 .text_color(cx.theme().popover_foreground)
116 .bg(cx.theme().tokens.popover)
117 118 .rounded(cx.theme().radius)
118 119 .justify_between()
119 120 .py_0p5()
@@ -91,6 +91,7 @@ impl Styled for Tooltip {
91}
91}
92impl Render for Tooltip {
92impl Render for Tooltip {
93 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
93 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
94 let flyout_fill = crate::elevation::flyout(window, cx).fill;
94 let key_binding = if let Some(key_binding) = &self.key_binding {
95 let key_binding = if let Some(key_binding) = &self.key_binding {
95 Some(key_binding.clone())
96 Some(key_binding.clone())
96 } else {
97 } else {
@@ -111,9 +112,9 @@ impl Render for Tooltip {
111 .h_flex()
112 .h_flex()
112 .font_family(cx.theme().font_family.clone())
113 .font_family(cx.theme().font_family.clone())
113 .m_3()
114 .m_3()
114 .bg(cx.theme().tokens.popover)
115 .bg(flyout_fill)
116 .shadow(crate::elevation::shadow8())
115 .text_color(cx.theme().popover_foreground)
117 .text_color(cx.theme().popover_foreground)
116 .bg(cx.theme().tokens.popover)
117 .rounded(cx.theme().radius)
118 .rounded(cx.theme().radius)
118 .justify_between()
119 .justify_between()
119 .py_0p5()
120 .py_0p5()
vendor/gpui-component/src/touch_selection/edit_menu.rs +2 −2
@@ -75,7 +75,7 @@ impl EditMenu {
75 75 }
76 76
77 77 impl RenderOnce for EditMenu {
78 fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement {
78 fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement {
79 79 let id = self.id;
80 80 let on_paint = self.on_paint;
81 81 // A pill-like bar, as iOS draws its edit menu.
@@ -136,7 +136,7 @@ impl RenderOnce for EditMenu {
136 136 .relative()
137 137 .items_stretch()
138 138 .overflow_hidden()
139 .popover_style(cx)
139 .popover_style(window, cx)
140 140 .rounded(radius)
141 141 .children(items)
142 142 .when_some(on_paint, |this, on_paint| {
@@ -75,7 +75,7 @@ impl EditMenu {
75}
75}
76
76
77impl RenderOnce for EditMenu {
77impl RenderOnce for EditMenu {
78 fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement {
78 fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement {
79 let id = self.id;
79 let id = self.id;
80 let on_paint = self.on_paint;
80 let on_paint = self.on_paint;
81 // A pill-like bar, as iOS draws its edit menu.
81 // A pill-like bar, as iOS draws its edit menu.
@@ -136,7 +136,7 @@ impl RenderOnce for EditMenu {
136 .relative()
136 .relative()
137 .items_stretch()
137 .items_stretch()
138 .overflow_hidden()
138 .overflow_hidden()
139 .popover_style(cx)
139 .popover_style(window, cx)
140 .rounded(radius)
140 .rounded(radius)
141 .children(items)
141 .children(items)
142 .when_some(on_paint, |this, on_paint| {
142 .when_some(on_paint, |this, on_paint| {