core: add film-grain overlay for materials

This commit is contained in:
2026-11-14 14:13:02 +07:00
parent db41b19e4a
commit 19154527f2
9 changed files with 145 additions and 2 deletions
+10
View File
@@ -12,6 +12,7 @@ use gpui_native_theme::{ActiveTheme as _, TextRole, Typeset as _};
use crate::button::{Button, ButtonVariant};
use crate::common::{DIALOG_LAYER, Sizable, v_flex};
use crate::grain::grain;
use crate::scroll_area::ScrollArea;
/// Requests the dialog's close: `false` closes.
@@ -26,6 +27,7 @@ pub struct Dialog {
id: ElementId,
open: bool,
alert: bool,
grain: bool,
title: Option<SharedString>,
a11y_label: Option<SharedString>,
on_change: Option<ChangeHandler>,
@@ -45,6 +47,7 @@ impl Dialog {
id: id.into(),
open: false,
alert: false,
grain: false,
title: None,
a11y_label: None,
on_change: None,
@@ -67,6 +70,12 @@ impl Dialog {
self
}
/// Textures the scrim with a film-grain overlay.
pub fn grain(mut self, grain: bool) -> Self {
self.grain = grain;
self
}
/// Requests close through `on_change` on escape, scrim clicks, and the close button.
pub fn on_change<F>(mut self, handler: F) -> Self
where
@@ -280,6 +289,7 @@ impl RenderOnce for Dialog {
.inset_0()
.bg(scrim_color)
.occlude()
.when(self.grain, |scrim| scrim.child(grain()))
.when(!alert, |scrim| {
scrim.on_mouse_down(MouseButton::Left, {
let on_change = on_change.clone();