core: add film-grain overlay for materials
This commit is contained in:
@@ -11,6 +11,7 @@ use gpui::{
|
||||
ParentElement as _, RenderOnce, Role, SharedString, StatefulInteractiveElement as _,
|
||||
Styled as _, Window, div,
|
||||
};
|
||||
use gpui_native_core::grain::grain as grain_overlay;
|
||||
use gpui_native_core::scroll_area::ScrollArea;
|
||||
use gpui_native_theme::{ActiveTheme as _, TextRole, Typeset as _};
|
||||
use gpui_native_utils::{nav_key, paint_selectable_row, selectable_label_color};
|
||||
@@ -118,6 +119,7 @@ pub struct Sidebar {
|
||||
id: ElementId,
|
||||
selected: Option<usize>,
|
||||
transparent: bool,
|
||||
grain: bool,
|
||||
a11y_label: Option<SharedString>,
|
||||
on_change: Option<ChangeHandler>,
|
||||
entries: Option<EntriesFn>,
|
||||
@@ -137,6 +139,7 @@ impl Sidebar {
|
||||
id: id.into(),
|
||||
selected: None,
|
||||
transparent: false,
|
||||
grain: false,
|
||||
a11y_label: None,
|
||||
on_change: None,
|
||||
entries: None,
|
||||
@@ -164,6 +167,13 @@ impl Sidebar {
|
||||
self.transparent
|
||||
}
|
||||
|
||||
/// Textures the material with a film-grain overlay; it renders only while
|
||||
/// the sidebar paints one.
|
||||
pub fn grain(mut self, grain: bool) -> Self {
|
||||
self.grain = grain;
|
||||
self
|
||||
}
|
||||
|
||||
/// Reports the next selected row, from clicks and keys alike.
|
||||
pub fn on_change<F>(mut self, handler: F) -> Self
|
||||
where
|
||||
@@ -234,6 +244,7 @@ impl RenderOnce for Sidebar {
|
||||
id,
|
||||
selected,
|
||||
transparent: material,
|
||||
grain,
|
||||
a11y_label,
|
||||
on_change,
|
||||
entries,
|
||||
@@ -381,6 +392,7 @@ impl RenderOnce for Sidebar {
|
||||
.child(body)
|
||||
.when_some(footer, |sidebar, footer| sidebar.child(footer))
|
||||
.when_some(overlay_strip, |sidebar, strip| sidebar.child(strip))
|
||||
.when(material && grain, |sidebar| sidebar.child(grain_overlay()))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user