Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 24 additions & 1 deletion crates/theme/src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ use std::sync::Arc;
use gpui::BorrowAppContext;
use gpui::Global;
use gpui::{
App, AssetSource, Hsla, Pixels, SharedString, WindowAppearance, WindowBackgroundAppearance, px,
App, AssetSource, Hsla, Pixels, SharedString, Styled, Tiling, WindowAppearance,
WindowBackgroundAppearance, px,
};
use serde::Deserialize;

Expand All @@ -49,6 +50,28 @@ pub const CLIENT_SIDE_DECORATION_ROUNDING: Pixels = px(10.0);
/// Defines window shadow size for platforms that use client side decorations.
pub const CLIENT_SIDE_DECORATION_SHADOW: Pixels = px(10.0);

/// Styling helpers for elements that follow client-side window decorations.
pub trait ClientDecorationsExt: Styled {
/// Rounds each corner whose two adjacent edges are both untiled.
fn rounded_client_corners(mut self, tiling: Tiling) -> Self {
if !tiling.top && !tiling.left {
self = self.rounded_tl(CLIENT_SIDE_DECORATION_ROUNDING);
}
if !tiling.top && !tiling.right {
self = self.rounded_tr(CLIENT_SIDE_DECORATION_ROUNDING);
}
if !tiling.bottom && !tiling.left {
self = self.rounded_bl(CLIENT_SIDE_DECORATION_ROUNDING);
}
if !tiling.bottom && !tiling.right {
self = self.rounded_br(CLIENT_SIDE_DECORATION_ROUNDING);
}
self
}
}

impl<T: Styled> ClientDecorationsExt for T {}

/// The appearance of the theme.
#[derive(Debug, PartialEq, Clone, Copy, Deserialize)]
pub enum Appearance {
Expand Down
1 change: 1 addition & 0 deletions crates/ui_prompt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ gpui.workspace = true
markdown.workspace = true
menu.workspace = true
settings.workspace = true
theme.workspace = true
theme_settings.workspace = true
ui.workspace = true
workspace.workspace = true
43 changes: 26 additions & 17 deletions crates/ui_prompt/src/ui_prompt.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use gpui::{
App, Entity, EventEmitter, FocusHandle, Focusable, PromptButton, PromptHandle, PromptLevel,
PromptResponse, RenderablePromptHandle, SharedString, TextStyleRefinement, Window, div,
prelude::*,
App, Decorations, Entity, EventEmitter, FocusHandle, Focusable, PromptButton, PromptHandle,
PromptLevel, PromptResponse, RenderablePromptHandle, SharedString, TextStyleRefinement, Window,
div, prelude::*,
};
use markdown::{Markdown, MarkdownElement, MarkdownStyle};
use settings::{Settings, SettingsStore};
use theme::ClientDecorationsExt;
use theme_settings::ThemeSettings;
use ui::{FluentBuilder, TintColor, prelude::*};
use workspace::WorkspaceSettings;
Expand Down Expand Up @@ -154,20 +155,28 @@ impl Render for ZedPromptRenderer {
})),
);

div()
.size_full()
.occlude()
.bg(gpui::black().opacity(0.2))
.child(
v_flex()
.size_full()
.absolute()
.top_0()
.left_0()
.items_center()
.justify_center()
.child(dialog),
)
let decorations = window.window_decorations();
let inset = window.client_inset().unwrap_or(Pixels::ZERO);

div().size_full().child(
v_flex()
.occlude()
.absolute()
.inset_0()
.bg(gpui::black().opacity(0.2))
.map(|this| match decorations {
Decorations::Server => this,
Decorations::Client { tiling } => this
.when(!tiling.top, |this| this.top(inset))
.when(!tiling.bottom, |this| this.bottom(inset))
.when(!tiling.left, |this| this.left(inset))
.when(!tiling.right, |this| this.right(inset))
.rounded_client_corners(tiling),
})
.items_center()
.justify_center()
.child(dialog),
)
}
}

Expand Down
66 changes: 9 additions & 57 deletions crates/workspace/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ use std::{
time::Duration,
};
use task::{DebugScenario, SharedTaskContext, SpawnInTerminal};
use theme::{ActiveTheme, SystemAppearance};
use theme::{ActiveTheme, ClientDecorationsExt, SystemAppearance};
use theme_settings::ThemeSettings;
pub use toolbar::{
PaneSearchBarCallbacks, Toolbar, ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView,
Expand Down Expand Up @@ -10498,6 +10498,12 @@ pub fn client_side_decorations(
Decorations::Server => Tiling::default(),
Decorations::Client { tiling } => tiling,
};
let corner_tiling = Tiling {
top: tiling.top || border_radius_tiling.top,
bottom: tiling.bottom || border_radius_tiling.bottom,
left: tiling.left || border_radius_tiling.left,
right: tiling.right || border_radius_tiling.right,
};

match decorations {
Decorations::Client { .. } => window.set_client_inset(theme::CLIENT_SIDE_DECORATION_SHADOW),
Expand All @@ -10513,34 +10519,7 @@ pub fn client_side_decorations(
.map(|div| match decorations {
Decorations::Server => div,
Decorations::Client { .. } => div
.when(
!(tiling.top
|| tiling.right
|| border_radius_tiling.top
|| border_radius_tiling.right),
|div| div.rounded_tr(theme::CLIENT_SIDE_DECORATION_ROUNDING),
)
.when(
!(tiling.top
|| tiling.left
|| border_radius_tiling.top
|| border_radius_tiling.left),
|div| div.rounded_tl(theme::CLIENT_SIDE_DECORATION_ROUNDING),
)
.when(
!(tiling.bottom
|| tiling.right
|| border_radius_tiling.bottom
|| border_radius_tiling.right),
|div| div.rounded_br(theme::CLIENT_SIDE_DECORATION_ROUNDING),
)
.when(
!(tiling.bottom
|| tiling.left
|| border_radius_tiling.bottom
|| border_radius_tiling.left),
|div| div.rounded_bl(theme::CLIENT_SIDE_DECORATION_ROUNDING),
)
.rounded_client_corners(corner_tiling)
.when(!tiling.top, |div| {
div.pt(theme::CLIENT_SIDE_DECORATION_SHADOW)
})
Expand Down Expand Up @@ -10595,34 +10574,7 @@ pub fn client_side_decorations(
Decorations::Server => div,
Decorations::Client { .. } => div
.border_color(cx.theme().colors().border)
.when(
!(tiling.top
|| tiling.right
|| border_radius_tiling.top
|| border_radius_tiling.right),
|div| div.rounded_tr(theme::CLIENT_SIDE_DECORATION_ROUNDING),
)
.when(
!(tiling.top
|| tiling.left
|| border_radius_tiling.top
|| border_radius_tiling.left),
|div| div.rounded_tl(theme::CLIENT_SIDE_DECORATION_ROUNDING),
)
.when(
!(tiling.bottom
|| tiling.right
|| border_radius_tiling.bottom
|| border_radius_tiling.right),
|div| div.rounded_br(theme::CLIENT_SIDE_DECORATION_ROUNDING),
)
.when(
!(tiling.bottom
|| tiling.left
|| border_radius_tiling.bottom
|| border_radius_tiling.left),
|div| div.rounded_bl(theme::CLIENT_SIDE_DECORATION_ROUNDING),
)
.rounded_client_corners(corner_tiling)
.when(!tiling.top, |div| div.border_t(BORDER_SIZE))
.when(!tiling.bottom, |div| div.border_b(BORDER_SIZE))
.when(!tiling.left, |div| div.border_l(BORDER_SIZE))
Expand Down
Loading