From e66f45d9eff5d9a112f17cdfa1164cec507d48df Mon Sep 17 00:00:00 2001 From: hl-valdemar Date: Mon, 12 Oct 2026 23:40:37 +0200 Subject: [PATCH] ui: restore visible caption Off and compact settings controls --- Checks/app-startup.py | 8 ++++++++ Checks/app-startup.swift | 22 ++++++++++++++++++++++ README.md | 6 +++--- Sources/App/TerebiApp.swift | 37 +++++++++++++++++++++++++++---------- 4 files changed, 60 insertions(+), 13 deletions(-) diff --git a/Checks/app-startup.py b/Checks/app-startup.py index 9eea0a0..1c86891 100644 --- a/Checks/app-startup.py +++ b/Checks/app-startup.py @@ -203,6 +203,14 @@ def check_cli_instances(root, app, fixtures): pid = next(pid for pid in states if pid not in previous) states = input_request(pid, count + index + 1, lambda state: state["status"] == 2, "resolved GUI pauses independently after decoded startup", action="pause") + states = input_request(pid, count + index + 1, + lambda state: state["selectedSubtitle"] == -1 and not state["subtitleText"], + "visible native Off item disables rendered captions", action="caption", label="Off") + states = input_request(pid, count + index + 1, + lambda state: state["selectedSubtitle"] == 0 + and state["subtitleText"] == f"Independent subtitle {index}", + "visible native track item restores rendered captions", + action="caption", label=f"Track {index} (en)") wait_report(report, [identity], lambda rows: any( row["event"] == "progress" and row["completion_eligible"] for row in rows), "resolved GUI owns v2 stable-identity reporting after CLI exit") diff --git a/Checks/app-startup.swift b/Checks/app-startup.swift index 9e773c4..ea3c63e 100644 --- a/Checks/app-startup.swift +++ b/Checks/app-startup.swift @@ -90,6 +90,14 @@ private enum CLIInstanceCheck { } } + static func captionSelector(in view: NSView) -> NSPopUpButton? { + if let selector = view as? NSPopUpButton, selector.toolTip == "Subtitles" { return selector } + for child in view.subviews { + if let selector = captionSelector(in: child) { return selector } + } + return nil + } + static func run(_ configuration: URL) { let settings = try! JSONSerialization.jsonObject(with: Data(contentsOf: configuration)) as! [String: String] let directory = URL(fileURLWithPath: settings["directory"]!, isDirectory: true) @@ -139,6 +147,20 @@ private enum CLIInstanceCheck { switch action { case "youtube": model.openYouTube(command["url"] as! String) + case "caption": + guard let view = window.contentView, let selector = captionSelector(in: view), + let cell = selector.cell as? NSPopUpButtonCell, let menu = selector.menu else { + fatalError("Native captions selector is missing") + } + cell.attachPopUp(withFrame: selector.bounds, in: selector) + menu.update() + let label = command["label"] as! String + guard let item = menu.items.first(where: { $0.title == label }) else { + fatalError("Requested native subtitle selection is missing") + } + precondition(!item.isHidden && item.isEnabled, "Subtitle selection must be visible and enabled") + cell.dismissPopUp() + precondition(selectMenuItem(label, in: menu), "Native subtitle selection must be actionable") case "seek": let position = command["position"] as! Double precondition(model.seekRelative(position - model.state.position), "Native seek must be accepted") diff --git a/README.md b/README.md index 1c2607b..542876c 100644 --- a/README.md +++ b/README.md @@ -251,15 +251,15 @@ The inline URL field, including its placeholder, uses the same 12-point system f With no media open, the full window uses native behind-window HUD glass with a 35%-opaque brown tint. Static, cached amber/rust radial gradients add ambient color only to the empty screen; they disappear during loading or errors, and are never drawn over video or playback chrome. Glass title/control/error surfaces use the same brown tint with half-point sand outlines. Decorative drawing does not intercept input. The idle Metal surface stays attached but hidden; opening media restores a solid black background and letterboxing without tinting the video, and closing it restores the ambient frosted background. macOS controls the material’s appearance, including Reduce Transparency. -The captions selector sits immediately right of the compact-mode button in both playback-control layouts and is disabled when no external subtitle tracks are available. Its explicitly sized native symbol has a 24-point footprint comparable to the compact-mode icon. The native pull-down menu prefers opening above the button; AppKit can reposition it to fit the screen. Subtitle text uses the floating controller's rounded HUD-glass background rather than an opaque black box. Subtitle-load errors remain visible independently of auto-hidden controls. +In normal mode, the captions selector sits immediately right of the compact-mode button and is disabled when no external subtitle tracks are available. Its native symbol uses a 17-point configuration within a 24-point click target. The native pull-down menu includes a visible Off option and prefers opening above the button; AppKit can reposition it to fit the screen. In compact mode, subtitle selection and Off are available through the settings button's Subtitles submenu. Subtitle text uses the floating controller's rounded HUD-glass background with 12-point internal padding. Subtitle-load errors remain visible independently of auto-hidden controls. -Normal and compact titlebars have no full-width glass strip or separator: content extends beneath AppKit’s transparent titlebar using `fullSizeContentView`, `titlebarAppearsTransparent`, and `titlebarSeparatorStyle = .none`. Titles retain their rounded HUD-glass backdrop. The pin and settings buttons share a separate container matching the title's height, horizontal padding, tint, outline and corner radius: 24 points high in normal mode and 28 in compact mode. Settings sits immediately right of the pin, and both retain 24-point click targets. Each title/button pair shares the same vertical inset; compact titles and buttons occupy the top row with 8-point outer insets, while title and progress remain adjacent. Native traffic lights and window dragging are preserved. +Normal and compact titlebars have no full-width glass strip or separator: content extends beneath AppKit’s transparent titlebar using `fullSizeContentView`, `titlebarAppearsTransparent`, and `titlebarSeparatorStyle = .none`. Titles retain their rounded HUD-glass backdrop. In normal mode, the pin and settings buttons share a separate container matching the title's 24-point height, horizontal padding, vertical inset, tint, outline and corner radius. Settings sits immediately right of the pin, and both retain 24-point click targets. That button container is not shown in compact mode; only the compact title and adjacent progress occupy the top row with 8-point outer insets. Native traffic lights and window dragging are preserved. Compact titles default to ` · <position> / <duration> <unit>`, using acknowledged playback position rather than slider previews. Total duration selects the format: below one minute, `12 / 45 s`; from one minute to below one hour, `05:12 / 42:08 m`; from one hour onward, `01:23 / 02:10 h`. Values truncate to the displayed precision. Set `[ui].compact_title_progress = "percentage"` to append only a whole percentage number (`<title> · 59`, without a percent sign), or `"none"` for title-only display. Percentages truncate and stay within 0–100. Loading, failed, live, unknown-duration and closed media have no progress suffix. Normal-mode titles remain unchanged. Opening video fits the window to its display aspect ratio, including non-square pixels, and constrains subsequent window resizing. Fullscreen retains the normal letterboxed renderer; audio-only playback and close release the aspect constraint. Extreme ratios that cannot fit both the screen and usable controls keep a freely resizable letterboxed window. -**Compact mode** uses the same window, Metal view, and playback session—not a second window or macOS system PiP. Use the PiP-shaped button in the normal playback controls, **⌃⌘P**, or **Playback Actions → Enter Compact Mode**. The compact-mode button replaces the fullscreen button; fullscreen remains available through its menu, keyboard shortcuts, and double-clicking normal-mode video. Compact mode starts at the current screen's top-right corner with a 16-point inset and the last manually chosen compact width (320 points before any resize). The width persists across mode changes and player restarts; height follows the current video's display aspect where usable screen bounds and the 160 × 90-point minimum allow, with extreme ratios retaining letterboxing. Normal-mode resize, transition animations, and automatic aspect/screen fitting do not overwrite the saved preference. Screen fitting may temporarily reduce the displayed size without reducing the saved width. Compact mode floats above ordinary windows, joins all Spaces, and is configured to join eligible other-app fullscreen spaces and Stage Manager sets. Small hover controls provide play/pause and restore, with the captions selector immediately right of restore; settings lives beside the titlebar pin. Keyboard playback controls remain available. +**Compact mode** uses the same window, Metal view, and playback session—not a second window or macOS system PiP. Use the PiP-shaped button in the normal playback controls, **⌃⌘P**, or **Playback Actions → Enter Compact Mode**. The compact-mode button replaces the fullscreen button; fullscreen remains available through its menu, keyboard shortcuts, and double-clicking normal-mode video. Compact mode starts at the current screen's top-right corner with a 16-point inset and the last manually chosen compact width (320 points before any resize). The width persists across mode changes and player restarts; height follows the current video's display aspect where usable screen bounds and the 160 × 90-point minimum allow, with extreme ratios retaining letterboxing. Normal-mode resize, transition animations, and automatic aspect/screen fitting do not overwrite the saved preference. Screen fitting may temporarily reduce the displayed size without reducing the saved width. Compact mode floats above ordinary windows, joins all Spaces, and is configured to join eligible other-app fullscreen spaces and Stage Manager sets. Its three-button hover row is play/pause, restore, then settings on the right. Settings includes subtitle selection and Off; keyboard playback controls remain available. Compact-mode shortcuts and menu actions remain available during YouTube URL resolution, media opening, and network buffering. While metadata is unavailable, the window uses a provisional video ratio; decoded metadata then updates its geometry without leaving compact mode. diff --git a/Sources/App/TerebiApp.swift b/Sources/App/TerebiApp.swift index 8002145..f7277ba 100644 --- a/Sources/App/TerebiApp.swift +++ b/Sources/App/TerebiApp.swift @@ -1328,8 +1328,7 @@ private struct CaptionSelector: NSViewRepresentable { imageScaling = .scaleProportionallyUpOrDown (cell as? NSPopUpButtonCell)?.arrowPosition = .noArrow let symbol = NSImage(systemSymbolName: "captions.bubble", accessibilityDescription: "Subtitles")? - .withSymbolConfiguration(.init(pointSize: 22, weight: .regular)) - symbol?.size = NSSize(width: 24, height: 24) + .withSymbolConfiguration(.init(pointSize: 17, weight: .regular)) captionItem.image = symbol contentTintColor = SunsetPalette.text toolTip = "Subtitles" @@ -1349,6 +1348,10 @@ private struct CaptionSelector: NSViewRepresentable { displayedSelection = model.selectedSubtitle let tracks = NSMenu() tracks.autoenablesItems = false + // AppKit reserves the first pull-down item for the button title. + let title = NSMenuItem(title: "Subtitles", action: nil, keyEquivalent: "") + title.isHidden = true + tracks.addItem(title) func add(_ label: String, index: Int?) { let item = NSMenuItem(title: label, action: #selector(selectTrack(_:)), keyEquivalent: "") item.target = self @@ -1522,7 +1525,7 @@ private struct PlayerContent: View { .frame(height: 24) .background(PlayerGlass(cornerRadius: 8).clipShape(RoundedRectangle(cornerRadius: 8)).allowsHitTesting(false)) Spacer(minLength: 12) - titleControls(compact: false) + titleControls } .padding(.leading, model.isFullScreen ? 16 : 86) .padding(.trailing, 12) @@ -1534,7 +1537,7 @@ private struct PlayerContent: View { .accessibilityHidden(!model.controlsVisible) } - private func titleControls(compact: Bool) -> some View { + private var titleControls: some View { HStack(spacing: 4) { iconButton(model.isOnTop ? "pin.fill" : "pin", model.isOnTop ? "Stop Keeping Window on Top" : "Keep Window on Top", action: model.toggleOnTop) @@ -1544,9 +1547,9 @@ private struct PlayerContent: View { actionsMenu } .padding(.horizontal, 8) - .frame(height: compact ? 28 : 24) - .background(PlayerGlass(cornerRadius: compact ? 10 : 8) - .clipShape(RoundedRectangle(cornerRadius: compact ? 10 : 8)).allowsHitTesting(false)) + .frame(height: 24) + .background(PlayerGlass(cornerRadius: 8) + .clipShape(RoundedRectangle(cornerRadius: 8)).allowsHitTesting(false)) } private var captionsMenu: some View { @@ -1562,6 +1565,21 @@ private struct PlayerContent: View { Divider() PlayerQualityMenu(model: model) Divider() + if model.isCompact { + Menu("Subtitles") { + Button("Off") { model.selectSubtitle(nil) } + ForEach(model.subtitleTracks.indices, id: \.self) { index in + Button { + model.selectSubtitle(index) + } label: { + Label(model.subtitleTracks[index].label + " (" + model.subtitleTracks[index].language + ")", + systemImage: model.selectedSubtitle == index ? "checkmark" : "text.bubble") + } + } + } + .disabled(model.subtitleTracks.isEmpty) + Divider() + } PlayerActionButton(model: model, action: model.bufferInfoAction, title: model.showsBufferInfo ? "Hide Buffer Info" : "Show Buffer Info") Divider() @@ -1590,7 +1608,7 @@ private struct PlayerContent: View { .disabled(!model.canTogglePlayback) iconButton("pip.exit", "Exit Compact Mode", action: model.toggleCompact) .disabled(!model.canToggleCompact) - captionsMenu + actionsMenu } if showsBufferReadout { bufferReadout } } @@ -1720,7 +1738,7 @@ private struct PlayerContent: View { .font(.system(size: max(16, min(28, geometry.size.width / 32)), weight: .semibold)) .foregroundStyle(.white) .multilineTextAlignment(.center) - .padding(8) + .padding(12) .background(PlayerGlass().clipShape(RoundedRectangle(cornerRadius: 12)).allowsHitTesting(false)) .padding(.horizontal, 24) .padding(.bottom, model.controlsVisible ? 110 : 24) @@ -1873,7 +1891,6 @@ private struct PlayerContent: View { .background(PlayerGlass(cornerRadius: 10).clipShape(RoundedRectangle(cornerRadius: 10)).allowsHitTesting(false)) .allowsHitTesting(false) Spacer(minLength: 0) - titleControls(compact: true) } .padding(8) .foregroundStyle(Color(SunsetPalette.text))