mirror of
https://github.com/horizon-rust/horizon.git
synced 2026-11-07 11:06:11 -10:00
Merge pull request #10129 from xFedeT/xfedet-launcher-transparent-topbar
Make launcher titlebar match Glass UI
This commit is contained in:
2 files changed
+43
-8
No files matched your search
+4
-3
@@ -286,9 +286,10 @@ page `servers.json` (the list), `servers/<name>/` (the servers created there) an
|
||||
Long pages, dialogs, the server console and data previews have a visible scrollbar when
|
||||
their content overflows. Drag the thumb or click the track to navigate without a mouse wheel.
|
||||
|
||||
Pages and Home's landscape fill the window as it resizes. Windows uses a matching title
|
||||
bar with native dragging, resizing, Snap,
|
||||
minimize, maximize/restore and close; macOS and Linux keep their system title bars.
|
||||
Pages and Home's landscape fill the window as it resizes. The title bar is transparent over the
|
||||
launcher on every platform: Windows keeps native dragging, resizing, Snap, minimize,
|
||||
maximize/restore and close; Linux keeps the same controls in its client-side title bar, while
|
||||
macOS keeps its native traffic-light controls.
|
||||
|
||||
## Updates
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@ use crate::theme::Theme;
|
||||
use gpui::{Div, TitlebarOptions, Window};
|
||||
use horizon_launcher::backend::Appearance;
|
||||
|
||||
/// Whether Windows uses a transparent native title bar for the launcher's custom chrome.
|
||||
/// Whether the launcher draws its own title bar and needs the native chrome to be transparent.
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
pub const DRAWN: bool = cfg!(target_os = "windows");
|
||||
|
||||
pub fn draws_brand(window: &Window) -> bool {
|
||||
@@ -23,12 +24,35 @@ pub fn draws_brand(window: &Window) -> bool {
|
||||
pub fn options() -> TitlebarOptions {
|
||||
TitlebarOptions {
|
||||
title: Some("Horizon".into()),
|
||||
appears_transparent: DRAWN,
|
||||
// macOS and Windows place the GPUI content under the native title bar. Linux uses
|
||||
// client-side decorations below, so its title bar is transparent by construction.
|
||||
appears_transparent: cfg!(any(target_os = "macos", target_os = "windows")),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(not(target_os = "windows"), not(target_os = "linux")))]
|
||||
/// Draw the macOS titlebar as a glass surface under the native traffic lights. The native
|
||||
/// titlebar remains transparent, so AppKit keeps its controls and window interactions.
|
||||
#[cfg(target_os = "macos")]
|
||||
pub fn render(theme: &Theme, _window: &Window) -> Option<Div> {
|
||||
use crate::glass::{self, Kind};
|
||||
use gpui::{div, prelude::*, px};
|
||||
|
||||
theme.glass.then(|| {
|
||||
div()
|
||||
.relative()
|
||||
.flex_none()
|
||||
.h(px(32.))
|
||||
.child(glass::backdrop(Kind::Glass, 0.))
|
||||
.text_color(theme.muted)
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
not(target_os = "windows"),
|
||||
not(target_os = "linux"),
|
||||
not(target_os = "macos")
|
||||
))]
|
||||
pub fn render(_theme: &Theme, _window: &Window) -> Option<Div> {
|
||||
None
|
||||
}
|
||||
@@ -36,6 +60,7 @@ pub fn render(_theme: &Theme, _window: &Window) -> Option<Div> {
|
||||
/// Draw the launcher's Linux title bar when the platform uses client-side decorations.
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn render(theme: &Theme, window: &Window) -> Option<Div> {
|
||||
use crate::glass::{self, Kind};
|
||||
use crate::{blocks, mark};
|
||||
use gpui::{div, prelude::*, px, Decorations, FontWeight, MouseButton};
|
||||
|
||||
@@ -57,11 +82,15 @@ pub fn render(theme: &Theme, window: &Window) -> Option<Div> {
|
||||
.child(blocks::pixel(13., FontWeight::MEDIUM).child("Horizon"));
|
||||
|
||||
let mut bar = div()
|
||||
.relative()
|
||||
.flex()
|
||||
.flex_none()
|
||||
.items_center()
|
||||
.h(px(32.))
|
||||
.bg(theme.side)
|
||||
.when(theme.glass, |bar| {
|
||||
bar.child(glass::backdrop(Kind::Glass, 0.))
|
||||
})
|
||||
.when(!theme.glass, |bar| bar.bg(theme.side))
|
||||
.text_color(theme.muted)
|
||||
.border_b_1()
|
||||
.border_color(theme.outline)
|
||||
@@ -287,6 +316,7 @@ pub fn apply_appearance(_: &Window, _: Appearance) {}
|
||||
#[cfg(target_os = "windows")]
|
||||
mod windows {
|
||||
use super::*;
|
||||
use crate::glass::{self, Kind};
|
||||
use crate::{blocks, mark};
|
||||
use gpui::{div, prelude::*, px, FontWeight, Stateful, WindowControlArea};
|
||||
|
||||
@@ -397,6 +427,7 @@ mod windows {
|
||||
.child(blocks::pixel(13., FontWeight::MEDIUM).child("Horizon"));
|
||||
Some(
|
||||
div()
|
||||
.relative()
|
||||
.flex()
|
||||
.flex_none()
|
||||
.items_center()
|
||||
@@ -405,7 +436,10 @@ mod windows {
|
||||
.when(!window.is_maximized(), |bar| {
|
||||
bar.pt(px(RESIZE_INSET)).px(px(RESIZE_INSET))
|
||||
})
|
||||
.bg(theme.side)
|
||||
.when(theme.glass, |bar| {
|
||||
bar.child(glass::backdrop(Kind::Glass, 0.))
|
||||
})
|
||||
.when(!theme.glass, |bar| bar.bg(theme.side))
|
||||
.text_color(theme.muted)
|
||||
.border_b_1()
|
||||
.border_color(theme.outline)
|
||||
|
||||
Reference in new issue
Block a user