gpui: Add support for window transparency & blur on macOS (#9610)
This PR adds support for transparent and blurred window backgrounds on macOS. Release Notes: - Added support for transparent and blurred window backgrounds on macOS ([#5040](https://github.com/zed-industries/zed/issues/5040)). - This requires themes to specify a new `background.appearance` key ("opaque", "transparent" or "blurred") and to include an alpha value in colors that should be transparent. <img width="913" alt="image" src="https://github.com/zed-industries/zed/assets/2588851/7547ee2a-e376-4d55-9114-e6fc2f5110bc"> <img width="994" alt="image" src="https://github.com/zed-industries/zed/assets/2588851/b36fbc14-6e4d-4140-9448-69cad803c45a"> <img width="1020" alt="image" src="https://github.com/zed-industries/zed/assets/2588851/d70e2005-54fd-4991-a211-ed484ccf26ef"> --------- Co-authored-by: Luiz Marcondes <luizgustavodevergennes@gmail.com> Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
This commit is contained in:
parent
1360dffead
commit
49144d94bf
20 changed files with 173 additions and 17 deletions
|
@ -190,6 +190,7 @@ pub(crate) trait PlatformWindow: HasWindowHandle + HasDisplayHandle {
|
|||
fn activate(&self);
|
||||
fn is_active(&self) -> bool;
|
||||
fn set_title(&mut self, title: &str);
|
||||
fn set_background_appearance(&mut self, background_appearance: WindowBackgroundAppearance);
|
||||
fn set_edited(&mut self, edited: bool);
|
||||
fn show_character_palette(&self);
|
||||
fn minimize(&self);
|
||||
|
@ -533,6 +534,9 @@ pub struct WindowOptions {
|
|||
/// The display to create the window on, if this is None,
|
||||
/// the window will be created on the main display
|
||||
pub display_id: Option<DisplayId>,
|
||||
|
||||
/// The appearance of the window background.
|
||||
pub window_background: WindowBackgroundAppearance,
|
||||
}
|
||||
|
||||
/// The variables that can be configured when creating a new window
|
||||
|
@ -555,6 +559,8 @@ pub(crate) struct WindowParams {
|
|||
pub show: bool,
|
||||
|
||||
pub display_id: Option<DisplayId>,
|
||||
|
||||
pub window_background: WindowBackgroundAppearance,
|
||||
}
|
||||
|
||||
impl Default for WindowOptions {
|
||||
|
@ -572,6 +578,7 @@ impl Default for WindowOptions {
|
|||
is_movable: true,
|
||||
display_id: None,
|
||||
fullscreen: false,
|
||||
window_background: WindowBackgroundAppearance::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -633,6 +640,27 @@ impl Default for WindowAppearance {
|
|||
}
|
||||
}
|
||||
|
||||
/// The appearance of the background of the window itself, when there is
|
||||
/// no content or the content is transparent.
|
||||
#[derive(Copy, Clone, Debug, Default, PartialEq)]
|
||||
pub enum WindowBackgroundAppearance {
|
||||
/// Opaque.
|
||||
///
|
||||
/// This lets the window manager know that content behind this
|
||||
/// window does not need to be drawn.
|
||||
///
|
||||
/// Actual color depends on the system and themes should define a fully
|
||||
/// opaque background color instead.
|
||||
#[default]
|
||||
Opaque,
|
||||
/// Plain alpha transparency.
|
||||
Transparent,
|
||||
/// Transparency, but the contents behind the window are blurred.
|
||||
///
|
||||
/// Not always supported.
|
||||
Blurred,
|
||||
}
|
||||
|
||||
/// The options that can be configured for a file dialog prompt
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct PathPromptOptions {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue