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
3 changes: 3 additions & 0 deletions .changeset/zoom-titlebar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Bug Fixes
- **Title bar at high zoom** - The title bar zooms with the rest of the app again. At 200% its menus, workspace switcher, window buttons and, on macOS, the open tabs stayed at 100% next to a 200% sidebar. The sidebar's top row now stays level with the bar and fits its buttons at every zoom.
- **Zoom pill no longer sticks** - The zoom level pill could stay on screen for good after clicking Reset or when it opened under the pointer. It now closes 2 seconds after the pointer leaves it, and right away on Reset, Escape, a click elsewhere, or when the window loses focus. It sits just under the title bar.
10 changes: 5 additions & 5 deletions src/lib/components/StudioShell.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -1183,11 +1183,11 @@
// lights, "History") and no status bar. Using the table view's heights there
// left the AI header showing above inset pages (shortcuts, connections) and
// its footer below them.
// The title bar is a fixed height at every zoom (TitleBar counter-zooms it),
// in AI mode too.
// Titlebar stays crisp desktop height: 38px on macOS (matches native
// unified toolbar / traffic lights), 36px on Windows/Linux.
root.style.setProperty('--app-titlebar-h', IS_MAC ? '38px' : '36px')
// The title bar is 38px on macOS (the traffic lights' row) and 36px on
// Windows and Linux at 100%, and grows with the app zoom like everything
// under it, in AI mode too. The sidebar's top row and the inset pages use
// the same value, so they stay level with the bar and fit their buttons.
root.style.setProperty('--app-titlebar-h', `calc(${IS_MAC ? 38 : 36}px * var(--app-scale, 1))`)
// The status bar is h-7 (28px at 100%), growing cleanly with app zoom.
root.style.setProperty('--app-statusbar-h', !aiMode && statusBarVisible ? 'calc(var(--spacing) * 7)' : '0px')
})
Expand Down
33 changes: 10 additions & 23 deletions src/lib/components/TitleBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import { onMount } from 'svelte'
import MessageSquare from '@lucide/svelte/icons/message-square'
import { cn } from '$lib/utils.js'
import { getAppScale } from '$lib/app-zoom.js'
import { detectOs } from '$lib/platform.js'
import { isTrialActive, licenseStatus } from '$lib/stores/license.js'
import Logo from './Logo.svelte'
import AppMenuBar from './AppMenuBar.svelte'
import { appMenuBar, appZoom } from '$lib/stores/settings.js'
import { appMenuBar } from '$lib/stores/settings.js'
import WindowControls from './WindowControls.svelte'
import TitleBarMenu from './TitleBarMenu.svelte'
import WorkspaceSwitcher from './WorkspaceSwitcher.svelte'
Expand Down Expand Up @@ -95,24 +94,12 @@
let titleW = $state(0)
const showTitle = $derived(crumbRoom > 0 && crumbRoom >= Math.min(titleW, 96))

// Fixed px like the bar itself: the macOS bar is a fixed 38px, so a rem
// control (42px at 150%) overflowed it. One 28px row at every zoom.
// The title bar never zooms, like the OS's own: the traffic lights beside it
// are drawn at 100% whatever the app zoom, so a bar that grew with the UI
// overflowed them (menus, workspace name and buttons all ballooned). It is
// counter-zoomed by 1/scale; its few px sizes are written × scale above so
// they land back on whole pixels. Menus it opens are portaled and still zoom.
// Tailwind's spacing (p-*, gap-*, h-*, size-*) is rem, and WebKitGTK does
// not apply `zoom` to rem lengths: on Linux the counter-zoom shrank the text
// back but left padding and gaps at the zoomed size, so the menu row spread
// out at every zoom step. Inside the bar the spacing unit is px x scale
// instead (style below), which every engine zooms back to the same 4px.
// Read in the same frame: applySettings sets --app-scale before it updates
// appZoom. Deferring it a frame made the bar jump after every zoom step.
const chromeZoom = $derived.by(() => {
void $appZoom
return 1 / getAppScale()
})
// The bar zooms with the rest of the UI. It used to be counter-zoomed to stay
// at 100% like an OS title bar, but at 200% that left the menus, workspace
// switcher and (on macOS) the open tabs at half the size of everything below
// them. Its height is --app-titlebar-h (StudioShell), which scales too, so the
// sidebar's top row and the inset pages stay level with it. Inside the bar the
// spacing unit is 4px x scale, the size it always had at 100%.

const iconBtn = 'inline-flex size-[calc(26px*var(--app-scale))] items-center justify-center rounded-md text-muted-foreground hover:bg-foreground/[0.06] hover:text-foreground active:bg-foreground/[0.1]'
</script>
Expand All @@ -124,9 +111,8 @@
style) floating over this bar, so it only reserves space for them here.
-->
<div
class="studio-chrome relative flex shrink-0 items-center border-b border-border/50 bg-panel {isMac ? 'h-[calc(38px*var(--app-scale))] pr-[calc(10px*var(--app-scale))]' : 'h-[calc(36px*var(--app-scale))] pl-[calc(10px*var(--app-scale))] pr-0'} select-none"
class="studio-chrome relative flex shrink-0 items-center border-b border-border/50 bg-panel h-(--app-titlebar-h) {isMac ? 'pr-[calc(10px*var(--app-scale))]' : 'pl-[calc(10px*var(--app-scale))] pr-0'} select-none"
data-studio-chrome
style:zoom={chromeZoom}
style:--spacing="calc(4px * var(--app-scale, 1))"
data-studio-region="titlebar"
bind:clientWidth={barW}
Expand All @@ -142,7 +128,8 @@
<!-- The lights sit over the sidebar's top row when it is open; with it
hidden they are over this bar, so it leaves them room. -->
<div class="flex shrink-0 items-center self-stretch" bind:clientWidth={leftW}>
{#if !sidebarWidth && !fullscreen}<div class="w-[calc(78px*var(--app-scale))] shrink-0"></div>{/if}
<!-- 78px at every zoom: the OS draws the lights at a fixed size. -->
{#if !sidebarWidth && !fullscreen}<div class="w-[78px] shrink-0"></div>{/if}
</div>

<!-- The content's top row: where you are, left-aligned from the sidebar's
Expand Down
5 changes: 3 additions & 2 deletions src/lib/components/WindowControls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@
const toggleMaximizeWindow = () => windowAction('toggleMaximize', (w) => w.toggleMaximize())
const closeWindow = () => windowAction('close', (w) => w.close())

// Windows 11 caption buttons: 46px wide, full titlebar height, square, crisp 10px
// Windows 11 caption buttons: 46px wide at 100% (scaled with the zoom, like
// the bar's height, so they keep their shape), full titlebar height, square, crisp 10px
// geometric Fluent glyphs, light hover fill and Windows red behind Close.
const winBtn =
'inline-flex h-full w-[46px] items-center justify-center text-foreground/80 hover:bg-foreground/[0.08] hover:text-foreground active:bg-foreground/[0.14]'
'inline-flex h-full w-[calc(46px*var(--app-scale))] items-center justify-center text-foreground/80 hover:bg-foreground/[0.08] hover:text-foreground active:bg-foreground/[0.14]'

// Linux (GNOME / GTK / Adwaita style): circular subtle controls inset cleanly
// from the window corner instead of Windows' sharp rectangular caption strip.
Expand Down
54 changes: 46 additions & 8 deletions src/lib/components/ZoomIndicator.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@
* the View menu, Settings, Ctrl+wheel). It listens for zoom gestures, not for
* the zoom value: the value is re-applied by every settings change and every
* sync, and following it made the pill appear at launch and flicker at random.
* Centred over the window; the level is centred in the pill; Reset shows
* beside it when you are off 100%. Hovering keeps it open.
* Centred just under the title bar; the level is centred in the pill; Reset
* shows beside it when you are off 100%. Hovering keeps it open.
*
* Hover is read from the pill itself (`:hover`) when the timer fires, never
* from a flag set on pointerenter. A flag only cleared on pointerleave stuck at
* true whenever that event never came (Reset unmounting under the pointer, the
* window losing focus, the pill opening under a still pointer), and the pill
* then stayed on screen for good. Reset, Escape, a click elsewhere and the
* window losing focus all close it.
*/
import { fade } from 'svelte/transition'
import { get } from 'svelte/store'
import { loadSettings, resetZoom, zoomGesture } from '$lib/stores/settings.js'

const HOLD_MS = 2000
Expand All @@ -16,13 +24,23 @@
let level = $state(1)
/** @type {ReturnType<typeof setTimeout> | undefined} */
let timer
let hovered = false
/** @type {HTMLElement | undefined} */
let pill = $state()
/** The count at mount: only gestures after it show the pill. */
let seen = -1

function hide() {
clearTimeout(timer)
shown = false
}

/** Close after HOLD_MS, or later while the pointer is still on the pill. */
function hideLater() {
clearTimeout(timer)
timer = setTimeout(() => { if (!hovered) shown = false }, HOLD_MS)
timer = setTimeout(() => {
if (pill?.matches(':hover')) hideLater()
else shown = false
}, HOLD_MS)
}

$effect(() => {
Expand All @@ -35,25 +53,45 @@
hideLater()
})

// resetZoom counts as a gesture; mark it seen so the pill closes instead of
// reopening at 100%.
function reset() {
resetZoom()
seen = get(zoomGesture)
hide()
}

/** @param {KeyboardEvent} e */
function onKey(e) {
if (shown && e.key === 'Escape') hide()
}

/** @param {PointerEvent} e */
function onPointerDown(e) {
if (shown && !(e.target instanceof Node && pill?.contains(e.target))) hide()
}

$effect(() => () => clearTimeout(timer))
</script>

<svelte:window onkeydown={onKey} onpointerdowncapture={onPointerDown} onblur={() => { if (shown) hide() }} />

{#if shown}
<div
class="chrome-font pointer-events-auto fixed top-[calc(48px*var(--app-scale))] left-1/2 z-[70] flex h-8 -translate-x-1/2 items-center justify-center gap-1 rounded-lg border border-border/70 bg-popover px-1 text-ui-xs text-popover-foreground elevate-2"
bind:this={pill}
class="chrome-font pointer-events-auto fixed top-[calc(var(--app-titlebar-h,38px)_+_8px)] left-1/2 z-[70] flex h-8 -translate-x-1/2 items-center justify-center gap-1 rounded-lg border border-border/70 bg-popover px-1 text-ui-xs text-popover-foreground elevate-2"
role="status"
aria-live="polite"
in:fade={{ duration: 120 }}
out:fade={{ duration: 160 }}
onpointerenter={() => { hovered = true; clearTimeout(timer) }}
onpointerleave={() => { hovered = false; hideLater() }}
onpointerleave={hideLater}
>
<span class="min-w-12 px-2 text-center font-medium tabular-nums">{Math.round(level * 100)}%</span>
{#if level !== 1}
<button
type="button"
class="h-6 rounded-md px-2 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring"
onclick={() => resetZoom()}
onclick={reset}
>
Reset
</button>
Expand Down
Loading