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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ All notable changes to Tarn are documented in this file. The format is based on

### Added

- Glass design: Settings › Appearance › Design (or View › Glass Design, or the command palette)
switches from Classic to Glass, which works with any theme: the window turns translucent over
your desktop with rounder, softer panels. Transparency, blur behind the window and corner
roundness are adjustable; transparency is held back as far as needed to keep text readable on a
light and a dark desktop. Classic stays the default. Translucent with blur on macOS, translucent on
Linux where the desktop composites windows; rounder, softer panels only on Windows, iOS and
Android.
- A video playing with sound moves into Picture in Picture when you switch to another tab, and
back into its page when you return; a window you opened yourself in that tab stays.
Settings › Tabs turns it off. macOS (WebKit tabs) and Windows.
Expand Down
10 changes: 9 additions & 1 deletion crates/app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ actions!(
]
);

actions!(tarn, [ReopenClosedTab, CloseAllTabs, DuplicateTab, CopyLink, CopyCleanLink, ToggleCompactToolbar, OpenAppMenu]);
actions!(tarn, [ReopenClosedTab, CloseAllTabs, DuplicateTab, CopyLink, CopyCleanLink, ToggleCompactToolbar, ToggleGlassDesign, OpenAppMenu]);
actions!(tarn, [AboutTarn, CheckForUpdates, RestartToUpdate, HideTarn, HideOthers, ShowAll, ToggleFullScreen, NewChromiumWindow, NewWindow]);
actions!(tarn, [NewGroup, ToggleLibrary, BookmarkTab, BookmarkAllTabs, ToggleAutoHideSidebar, ToggleDownloads]);
actions!(tarn, [Tab1, Tab2, Tab3, Tab4, Tab5, Tab6, Tab7, Tab8, LastTab, NextTab, PreviousTab, BurnerTab]);
Expand All @@ -126,6 +126,7 @@ pub(crate) fn command_action(command: browser_core::palette::Command) -> Option<
C::TabsOnTop => &ToggleTabsOnTop,
C::AutoHideSidebar => &ToggleAutoHideSidebar,
C::CompactToolbar => &ToggleCompactToolbar,
C::GlassDesign => &ToggleGlassDesign,
C::CloseAllTabs => &CloseAllTabs,
C::ShowLibrary => &ToggleLibrary,
C::SaveSnapshot => &library::SaveSnapshot,
Expand Down Expand Up @@ -444,6 +445,13 @@ impl Browser {
}))
})
.on_action(cx.listener(|b, _: &ToggleCompactToolbar, _, cx| b.set_pref(prefs::Pref::CompactToolbar, !b.pref(prefs::Pref::CompactToolbar), cx)))
.on_action(cx.listener(|b, _: &ToggleGlassDesign, _, cx| {
let on = browser_core::theme_library::glass_on(&b.core.disk);
if let Err(e) = browser_core::theme_library::set_glass_on(&b.core.disk, !on) {
b.show_toast_as(browser_core::toast::Tone::Warning, e, None, cx);
}
cx.defer(themes::changed);
}))
.on_action(cx.listener(|b, _: &OpenAppMenu, window, cx| b.open_app_menu(window, cx)))
.on_action(cx.listener(|b, _: &FocusNextRegion, w, cx| b.cycle_focus(false, w, cx)))
.on_action(cx.listener(|b, _: &FocusPreviousRegion, w, cx| b.cycle_focus(true, w, cx)))
Expand Down
2 changes: 2 additions & 0 deletions crates/app/src/menubar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ impl Browser {
self.model.active.and_then(|k| self.pinned_drift(k)).map(|u| u.host_str().map(str::to_owned)).hash(&mut hash);
(self.model.active.is_some_and(|a| self.splits.contains(a)), self.site().is_some(), self.reader_shown()).hash(&mut hash);
(self.sidebar_open, self.tab_placement, self.pref(crate::prefs::Pref::CompactToolbar), self.pref(crate::prefs::Pref::AutoHideSidebar)).hash(&mut hash);
self.core.themes.borrow().glass.hash(&mut hash);
let signature = hash.finish();
if self.menu.signature != signature {
self.menu.signature = signature;
Expand Down Expand Up @@ -388,6 +389,7 @@ impl Browser {
view.item("Tabs on Top", Box::new(crate::ToggleTabsOnTop), None, self.tab_placement == browser_core::layout::TabPlacement::Top),
view.item("Compact Toolbar", Box::new(crate::ToggleCompactToolbar), None, compact),
view.item("Auto-Hide Sidebar", Box::new(crate::ToggleAutoHideSidebar), None, auto_hide),
view.item("Glass Design", Box::new(crate::ToggleGlassDesign), None, self.core.themes.borrow().glass),
MenuItem::separator(),
view.action("Reload", crate::Reload),
view.action("Reload Without Cache", crate::ReloadFromOrigin),
Expand Down
9 changes: 5 additions & 4 deletions crates/app/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use browser_core::library::HistoryRange;
use gpui::{
AnyElement, App, AppContext, Bounds, Context, Div, FocusHandle, Focusable, FontWeight, InteractiveElement, IntoElement, KeyDownEvent, MouseButton,
MouseMoveEvent, ParentElement, Pixels, PromptLevel, Render, RenderImage, SharedString, Stateful, StatefulInteractiveElement, Styled, Subscription,
TitlebarOptions, WeakEntity, Window, WindowBackgroundAppearance, WindowBounds, WindowHandle, WindowOptions, canvas, div, img, point,
prelude::FluentBuilder, px, rgb, size,
TitlebarOptions, WeakEntity, Window, WindowBounds, WindowHandle, WindowOptions, canvas, div, img, point, prelude::FluentBuilder, px, rgb, size,
};
use shield::ShieldLevel;
use std::cell::Cell;
Expand Down Expand Up @@ -81,7 +80,7 @@ const PANES: [(SettingsPane, Icon, &str, &str, &str); 14] = [
Icon::Palette,
"Appearance",
"Theme, accent colour, motion and layout.",
"theme dark light match system accent colour color motion reduce toolbar compact density sidebar search bar effect tips",
"theme dark light match system accent colour color motion reduce toolbar compact density sidebar search bar effect tips design glass liquid transparency translucent blur corners round",
),
(
SettingsPane::Tabs,
Expand Down Expand Up @@ -338,7 +337,7 @@ impl SettingsWindow {
// AppKit only hit-tests the buttons inside its titlebar strip, so they stay within it.
traffic_light_position: Some(point(px(18.), px(10.))),
}),
window_background: WindowBackgroundAppearance::Opaque,
window_background: crate::themes::window_background(),
is_minimizable: false,
..Default::default()
};
Expand Down Expand Up @@ -1018,6 +1017,8 @@ impl SettingsWindow {
.child(section("Theme"))
.child(group().children(self.theme_rows(cx)).child(row(false).child(text_block("Accent", "Buttons, selection and focus.")).child(accents)))
.child(self.theme_sections(window, cx))
.child(section("Design"))
.child(group().children(self.design_rows(cx)))
.child(section("Motion"))
.child(group().child(reduce_motion).child(self.search_effect_row(false, cx)))
.child(section("Tips"))
Expand Down
70 changes: 70 additions & 0 deletions crates/app/src/settings/appearance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,76 @@ impl SettingsWindow {
self.report(saved, "Appearance reset to Tarn.", cx);
}

pub(super) fn design_rows(&self, cx: &mut Context<Self>) -> Vec<AnyElement> {
let core = crate::shared::core(cx);
let on = library::glass_on(&core.disk);
let glass = library::glass_settings(&core.disk);
let (reached, safe) = (core.themes.borrow().reached, core.themes.borrow().safe);
let mut rows = vec![
wide_row(
true,
text_block(
"Design",
if cfg!(target_os = "macos") {
"Glass makes the window translucent over your desktop, with rounder, softer panels."
} else {
"Glass gives rounder, softer panels."
},
),
Self::picks("design", on, [("Classic", false), ("Glass", true)], library::set_glass_on, cx),
)
.into_any_element(),
];
if !on {
return rows;
}
let corners = browser_core::theme::Corners::ALL.map(|c| (c.label(), c));
let corners =
wide_row(false, text_block("Corners", "How round panels and cards are."), Self::picks("corners", glass.corners, corners, library::set_corners, cx))
.into_any_element();
if !cfg!(target_os = "macos") {
rows.push(corners);
return rows;
}
let steps = library::TRANSPARENCY_STEPS.map(|v| (format!("{v} %"), v));
rows.push(
wide_row(
false,
text_block("Transparency", library::transparency_note(glass.transparency, reached, safe)),
Self::picks("transparency", glass.transparency, steps, library::set_transparency, cx),
)
.into_any_element(),
);
let blur = glass.blur;
rows.push(
switch_row("glass-blur", false, text_block("Blur behind the window", "Off shows the desktop sharp behind the window."), blur)
.on_click(cx.listener(move |this, _, _, cx| {
let saved = library::set_blur(&crate::shared::core(cx).disk, !blur);
this.report(saved, "", cx);
this.appearance.message = this.appearance.message.take().filter(|(error, _)| *error);
}))
.into_any_element(),
);
rows.push(corners);
rows
}

fn picks<T: Copy + PartialEq + 'static, const N: usize>(
key: &'static str,
current: T,
choices: [(impl Into<SharedString>, T); N],
set: fn(&store::Store, T) -> Result<(), String>,
cx: &mut Context<Self>,
) -> gpui::Div {
segmented().children(choices.into_iter().enumerate().map(|(ix, (label, value))| {
tab_stop(segment((key, ix), label, value == current)).on_click(cx.listener(move |this, _, _, cx| {
let saved = set(&crate::shared::core(cx).disk, value);
this.report(saved, "", cx);
this.appearance.message = this.appearance.message.take().filter(|(error, _)| *error);
}))
}))
}

pub(super) fn search_effect_row(&self, first: bool, cx: &mut Context<Self>) -> gpui::Div {
use browser_core::effects::Effect;
let stored = library::chosen_effect(&crate::shared::core(cx).disk);
Expand Down
6 changes: 2 additions & 4 deletions crates/app/src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use browser_core::windows::{Frame, onto_screen};
use engine::Event;
use futures::StreamExt;
use futures::channel::{mpsc, oneshot};
use gpui::{
App, AppContext, Bounds, DisplayId, Global, Pixels, TitlebarOptions, Window, WindowBackgroundAppearance, WindowBounds, WindowOptions, point, px, size,
};
use gpui::{App, AppContext, Bounds, DisplayId, Global, Pixels, TitlebarOptions, Window, WindowBounds, WindowOptions, point, px, size};
use store::{Id, SavedWindow};

use crate::browser::{Browser, WindowStart, data_dir};
Expand Down Expand Up @@ -562,7 +560,7 @@ pub(crate) fn open_window(
window_bounds: Some(WindowBounds::Windowed(Bounds::new(point(px(x), px(y)), size(px(width), px(height))))),
display_id: display,
titlebar: Some(TitlebarOptions { title: Some("Tarn".into()), appears_transparent: true, traffic_light_position: Some(point(px(20.), px(17.))) }),
window_background: WindowBackgroundAppearance::Opaque,
window_background: crate::themes::window_background(),
window_min_size: Some(size(px(720.), px(480.))),
..Default::default()
};
Expand Down
9 changes: 5 additions & 4 deletions crates/app/src/sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,11 @@ fn mix(from: Option<Rgba>, to: Option<Rgba>, t: f32) -> Option<Rgba> {
Some(Rgba { r: lerp(a.r, b.r), g: lerp(a.g, b.g), b: lerp(a.b, b.b), a: lerp(a.a, b.a) })
}

fn background(b: &Browser) -> Background {
fn background(b: &Browser, card: bool) -> Background {
let tint = |ix: usize| b.model.spaces.get(ix).and_then(space_tint);
let (other, shown) = b.slide_other().map_or((None, 0.), |(ix, _, shown)| (tint(ix), shown));
mix(tint(b.model.space_ix), other, shown).map_or_else(Theme::sidebar, Theme::sidebar_tinted)
mix(tint(b.model.space_ix), other, shown)
.map_or_else(|| if card { Theme::sidebar_solid() } else { Theme::sidebar() }, |tint| Theme::sidebar_tinted(tint, card))
}

pub fn group_color(g: &Group) -> Rgba {
Expand Down Expand Up @@ -363,7 +364,7 @@ pub fn render(b: &mut Browser, cx: &mut Context<Browser>) -> AnyElement {
if !cx.has_active_drag() {
b.split_drop = None;
}
let bg = background(b);
let bg = background(b, false);
content(b, NOTCH_WIDTH + 10., cx)
.relative()
.w(px(b.sidebar_width))
Expand Down Expand Up @@ -411,7 +412,7 @@ fn resize_handle(cx: &mut Context<Browser>) -> impl IntoElement {
/// visible above it. It slides in from the window's left edge and fully back out, fading as it goes.
pub fn floating(b: &mut Browser, height: Pixels, closing: bool, cx: &mut Context<Browser>) -> AnyElement {
let width = b.sidebar_width;
let bg = background(b);
let bg = background(b, true);
let card = content(b, TILE_GAP + 4., cx)
.absolute()
.top_0()
Expand Down
47 changes: 43 additions & 4 deletions crates/app/src/themes.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use browser_core::theme::{Active, Selection};
use gpui::{App, WindowAppearance};
use std::sync::atomic::{AtomicU8, Ordering};

use gpui::{App, WindowAppearance, WindowBackgroundAppearance};
use ui::theme::Theme;

use crate::shared::AppCore;
Expand All @@ -11,6 +13,8 @@ pub(crate) struct State {
/// Shift was held at launch: the built-in theme shows, without page styles, until quit.
pub safe: bool,
pub system_light: bool,
pub reached: u8,
pub glass: bool,
}

pub(crate) fn merge_revocations(core: &AppCore, list: &shield::revocations::Revocations) -> bool {
Expand All @@ -28,12 +32,47 @@ pub(crate) fn apply(core: &AppCore, system_light: bool) {
state.system_light = system_light;
let active = browser_core::theme_library::current(&core.disk, system_light, state.safe);
let p = &active.parsed;
Theme::set_tokens(p.tokens, p.meta.scheme, p.font.clone());
let can = if cfg!(target_os = "macos") { browser_core::theme::Backing::Blurred } else { browser_core::theme::Backing::Opaque };
let look = browser_core::theme_library::look(&core.disk, &active, state.safe, can);
Theme::set_tokens(look.tokens, p.meta.scheme, p.font.clone());
let backing = match look.window {
browser_core::theme::Backing::Opaque => OPAQUE,
browser_core::theme::Backing::Clear => CLEAR,
browser_core::theme::Backing::Blurred => BLURRED,
};
BACKING.store(backing, Ordering::Relaxed);
state.reached = look.transparency;
state.glass = browser_core::theme_library::glass_on(&core.disk);
crate::prefs::apply_accent(&core.disk);
Theme::set_search_effect(browser_core::theme_library::search_effect(&core.disk, &active));
state.active = Some(active);
}

static BACKING: AtomicU8 = AtomicU8::new(OPAQUE);
const OPAQUE: u8 = 0;
const CLEAR: u8 = 1;
const BLURRED: u8 = 2;

pub(crate) fn window_background() -> WindowBackgroundAppearance {
match BACKING.load(Ordering::Relaxed) {
CLEAR => WindowBackgroundAppearance::Transparent,
BLURRED => WindowBackgroundAppearance::Blurred,
_ => WindowBackgroundAppearance::Opaque,
}
}

/// Deferred, as the caller may be inside the update of one of these windows.
fn refresh(cx: &mut App) {
cx.defer(|cx| {
let shells =
cx.windows().into_iter().filter(|w| w.downcast::<crate::browser::Browser>().is_some() || w.downcast::<crate::settings::SettingsWindow>().is_some());
for handle in shells.collect::<Vec<_>>() {
handle.update(cx, |_, window, _| window.set_background_appearance(window_background())).ok();
}
cx.refresh_windows();
});
}

/// Applies the stored theme choice after it or a theme changed, and redraws every window. Pages
/// get changed website styles as they load; Chromium views, which keep the script they were made
/// with, are made again (macOS; on Windows `set_site_styles` restyles open pages and is
Expand All @@ -43,7 +82,7 @@ pub(crate) fn changed(cx: &mut App) {
if !moved.is_empty() {
crate::shared::each(cx, |b, window, cx| b.restart_views_of(&moved, true, window, cx));
}
cx.refresh_windows();
refresh(cx);
}

/// Loads the theme and hands every open profile its sheets; returns the profiles whose sheets
Expand Down Expand Up @@ -77,7 +116,7 @@ pub(crate) fn enter_safe_mode(core: &AppCore, cx: &mut App) {
if !moved.is_empty() {
crate::shared::each(cx, |b, window, cx| b.restart_views_of(&moved, false, window, cx));
}
cx.refresh_windows();
refresh(cx);
}

/// Called when macOS switches between light and dark: only a "Match system" choice follows it.
Expand Down
2 changes: 2 additions & 0 deletions crates/browser-core/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ pub const GLYPHS: &[(&str, &str)] = &[
("Toggle Sidebar", "sidebar"),
("Auto-Hide Sidebar", "sidebar"),
("Compact Toolbar", "app-window"),
("Glass Design", "sparkles"),
("Close All Tabs", "close"),
("Close Duplicate Tabs", "copy"),
("Close Split View", "close"),
Expand Down Expand Up @@ -783,6 +784,7 @@ mod tests {
"Show Tabs in Sidebar",
"Classic Toolbar",
"Compact Toolbar",
"Glass Design",
"Site Settings…",
];
for label in labels {
Expand Down
4 changes: 3 additions & 1 deletion crates/browser-core/src/palette.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ pub enum Command {
TabsOnTop,
AutoHideSidebar,
CompactToolbar,
GlassDesign,
CloseAllTabs,
ShowLibrary,
SaveSnapshot,
Expand Down Expand Up @@ -123,7 +124,7 @@ pub enum Command {
AskPage,
}

pub const COMMANDS: [(&str, &str, Command); 73] = [
pub const COMMANDS: [(&str, &str, Command); 74] = [
("Settings", "preferences options", Command::Settings),
("Open File\u{2026}", "local disk html pdf image text document view", Command::OpenFile),
("New Tab Group", "group", Command::NewGroup),
Expand All @@ -142,6 +143,7 @@ pub const COMMANDS: [(&str, &str, Command); 73] = [
("Tabs on Top", "layout strip horizontal sidebar", Command::TabsOnTop),
("Auto-Hide Sidebar", "floating", Command::AutoHideSidebar),
("Compact Toolbar", "toggle address", Command::CompactToolbar),
("Glass Design", "liquid classic translucent transparent blur appearance look", Command::GlassDesign),
("Close All Tabs", "clear", Command::CloseAllTabs),
("Show Library", "bookmarks history", Command::ShowLibrary),
("Save Space as Snapshot", "session tabs save", Command::SaveSnapshot),
Expand Down
Loading
Loading