feat(capture): choose what to capture — area, window, browser page or screen
Capture is now a decision, not a hidden setting. The popover shows a four-way scope control with the target named under it (800 x 600 on Display 1, the frontmost window, the front browser window, the whole display), and the window header carries the same choice beside the verbs. Picking Window or Browser hides Redline, dims the screen, names the app under the pointer and highlights its window; a click captures exactly that window, Escape cancels, and the desktop highlights the whole screen. New Session is one click: the current captures stay in their own folder, a fresh session opens, and the area picker comes straight up with the saved area pre-selected — Return keeps it, a drag replaces it. Settings is consolidated into one door (the popover gear, plus Cmd-,): what to capture, saved area, shortcut, ask-on-new-session, sending, session age limit, and a new Updates group with automatic install (on by default; installs only when nothing is unsent). The footer filler and the extra-actions menu are gone.
This commit is contained in:
@@ -2,26 +2,22 @@ import AppKit
|
||||
import SwiftUI
|
||||
import ShotdeckCore
|
||||
|
||||
/// The menu-bar popover: the current session, and the two things you do with it.
|
||||
///
|
||||
/// Everything else — history, review details, PDF facts — lives in the Redline
|
||||
/// window, which stays open and has room for it.
|
||||
/// The menu-bar popover: decide what to capture, see the pages, then capture or send.
|
||||
/// History, editable details and file facts live in the Redline window; Settings has
|
||||
/// exactly one door — the gear here (⌘, works anywhere).
|
||||
struct MenuBarView: View {
|
||||
@Environment(AppModel.self) private var model
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
if model.screenRecordingGranted {
|
||||
sessionHeader
|
||||
thumbnailRow
|
||||
statusRow
|
||||
actionRows
|
||||
Divider()
|
||||
footer
|
||||
header
|
||||
scopeControl
|
||||
pageStrip
|
||||
newsRow
|
||||
verbs
|
||||
} else {
|
||||
permissionBlock
|
||||
Divider()
|
||||
footer
|
||||
}
|
||||
}
|
||||
.padding(10)
|
||||
@@ -31,7 +27,7 @@ struct MenuBarView: View {
|
||||
|
||||
// MARK: - Header
|
||||
|
||||
private var sessionHeader: some View {
|
||||
private var header: some View {
|
||||
HStack(alignment: .top, spacing: 8) {
|
||||
VStack(alignment: .leading, spacing: 1) {
|
||||
HStack(spacing: 5) {
|
||||
@@ -50,18 +46,8 @@ struct MenuBarView: View {
|
||||
.foregroundStyle(.secondary)
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
.help(detailLine)
|
||||
}
|
||||
Spacer(minLength: 4)
|
||||
if !model.session.isEmpty {
|
||||
Text("\(model.session.captures.count) page\(model.session.captures.count == 1 ? "" : "s")")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.monospacedDigit()
|
||||
.padding(.horizontal, 6)
|
||||
.padding(.vertical, 2)
|
||||
.background(.quaternary, in: Capsule())
|
||||
}
|
||||
Button {
|
||||
presentWindow(focusLane: true)
|
||||
} label: {
|
||||
@@ -71,6 +57,17 @@ struct MenuBarView: View {
|
||||
.buttonStyle(.borderless)
|
||||
.help("Edit review details")
|
||||
.accessibilityLabel("Edit review details")
|
||||
|
||||
Button {
|
||||
(model as? SettingsWindowPresenting)?.presentSettingsWindow()
|
||||
} label: {
|
||||
Image(systemName: "gearshape")
|
||||
.font(.system(size: 12, weight: .semibold))
|
||||
}
|
||||
.buttonStyle(.borderless)
|
||||
.keyboardShortcut(",", modifiers: .command)
|
||||
.help("Settings (⌘,)")
|
||||
.accessibilityLabel("Settings")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,20 +86,55 @@ struct MenuBarView: View {
|
||||
var parts: [String] = []
|
||||
if !context.commit.isEmpty { parts.append(context.commit) }
|
||||
if !context.reviewer.isEmpty { parts.append(context.reviewer) }
|
||||
let started = DubaiTime.checkTime(model.session.createdAt)
|
||||
if parts.isEmpty {
|
||||
return "No review details yet · started \(started)"
|
||||
}
|
||||
return parts.joined(separator: " · ") + " · started \(started)"
|
||||
let pages = model.session.captures.count
|
||||
parts.append(pages == 0 ? "no pages" : "\(pages) page\(pages == 1 ? "" : "s")")
|
||||
return parts.joined(separator: " · ")
|
||||
}
|
||||
|
||||
// MARK: - Body
|
||||
// MARK: - What to capture
|
||||
|
||||
private var scopeControl: some View {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Picker("Capture", selection: scopeBinding) {
|
||||
ForEach(CaptureScope.allCases, id: \.self) { scope in
|
||||
Text(scope.displayName).tag(scope)
|
||||
}
|
||||
}
|
||||
.pickerStyle(.segmented)
|
||||
.labelsHidden()
|
||||
.accessibilityLabel("Capture")
|
||||
|
||||
HStack(spacing: 6) {
|
||||
Text(model.captureTargetDescription)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
Spacer(minLength: 4)
|
||||
if model.captureScope == .area {
|
||||
Button("Choose Area…") {
|
||||
Task { await model.rePickRegion() }
|
||||
}
|
||||
.buttonStyle(.link)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var scopeBinding: Binding<CaptureScope> {
|
||||
Binding(
|
||||
get: { model.captureScope },
|
||||
set: { scope in Task { await model.chooseCaptureScope(scope) } }
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Pages
|
||||
|
||||
@ViewBuilder
|
||||
private var thumbnailRow: some View {
|
||||
private var pageStrip: some View {
|
||||
if model.session.isEmpty {
|
||||
VStack(spacing: 2) {
|
||||
Text("Nothing captured yet")
|
||||
Text("No pages yet")
|
||||
.font(.callout)
|
||||
.foregroundStyle(.secondary)
|
||||
Text(emptyHint)
|
||||
@@ -117,28 +149,26 @@ struct MenuBarView: View {
|
||||
}
|
||||
|
||||
private var emptyHint: String {
|
||||
guard let region = model.region else {
|
||||
return "\(model.hotkeyDisplayString) picks an area, then captures it"
|
||||
}
|
||||
return "\(model.hotkeyDisplayString) captures \(Int(region.rect.width)) × \(Int(region.rect.height)) on \(displayName(for: region))"
|
||||
"\(model.hotkeyDisplayString) captures the \(model.captureScope.displayName.lowercased())"
|
||||
}
|
||||
|
||||
private func displayName(for region: CaptureRegion) -> String {
|
||||
for (index, screen) in NSScreen.screens.enumerated() {
|
||||
let id = (screen.deviceDescription[NSDeviceDescriptionKey("NSScreenNumber")] as? NSNumber)?
|
||||
.uint32Value
|
||||
if id == region.displayID {
|
||||
return "Display \(index + 1)"
|
||||
}
|
||||
}
|
||||
return "Display 1"
|
||||
}
|
||||
// MARK: - News
|
||||
|
||||
/// One line, only when there is something to say: the last action's result, or a
|
||||
/// PDF that came back with marks.
|
||||
@ViewBuilder
|
||||
private var statusRow: some View {
|
||||
if let status = model.statusLine, !status.isEmpty {
|
||||
private var newsRow: some View {
|
||||
if let update = model.updateAvailable {
|
||||
HStack(spacing: 6) {
|
||||
Circle().fill(.green).frame(width: 6, height: 6)
|
||||
Text(model.autoInstallUpdates
|
||||
? "Redline \(update.version) is ready — restarts when nothing is unsent"
|
||||
: "Redline \(update.version) is ready")
|
||||
.font(.caption)
|
||||
.lineLimit(2)
|
||||
Spacer(minLength: 4)
|
||||
Button("Restart Now") { model.installUpdate() }
|
||||
.buttonStyle(.link)
|
||||
}
|
||||
} else if let status = model.statusLine, !status.isEmpty {
|
||||
Text(status)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
@@ -147,7 +177,9 @@ struct MenuBarView: View {
|
||||
}
|
||||
}
|
||||
|
||||
private var actionRows: some View {
|
||||
// MARK: - Verbs
|
||||
|
||||
private var verbs: some View {
|
||||
VStack(spacing: 6) {
|
||||
HStack(spacing: 6) {
|
||||
Button {
|
||||
@@ -165,10 +197,7 @@ struct MenuBarView: View {
|
||||
.disabled(model.isCapturing)
|
||||
|
||||
Button {
|
||||
guard let sender = model as? SendCapable else {
|
||||
model.setStatus("Send is not available in this build.")
|
||||
return
|
||||
}
|
||||
guard let sender = model as? SendCapable else { return }
|
||||
let anchor = NSApp.keyWindow?.contentView
|
||||
Task { await sender.send(anchor: anchor) }
|
||||
} label: {
|
||||
@@ -185,7 +214,7 @@ struct MenuBarView: View {
|
||||
|
||||
HStack(spacing: 6) {
|
||||
Button {
|
||||
Task { await model.startNewSession() }
|
||||
Task { await model.newSession() }
|
||||
} label: {
|
||||
HStack(spacing: 4) {
|
||||
Image(systemName: "plus.square.on.square")
|
||||
@@ -194,8 +223,8 @@ struct MenuBarView: View {
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.controlSize(.regular)
|
||||
.disabled(!model.canStartNewSession)
|
||||
.help("Keeps this session and starts a fresh one. Nothing is deleted.")
|
||||
.disabled(model.isSending)
|
||||
.help("Keeps this session and starts a fresh one, then asks where to capture.")
|
||||
|
||||
Button {
|
||||
presentWindow(focusLane: false)
|
||||
@@ -219,53 +248,7 @@ struct MenuBarView: View {
|
||||
return model.transport == .oneDrive ? "Save \(pages)…" : "Send \(pages)…"
|
||||
}
|
||||
|
||||
// MARK: - Footer
|
||||
|
||||
private var footer: some View {
|
||||
HStack(spacing: 6) {
|
||||
Text("\(sendChannel) · \(model.retentionSummary)")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
Spacer(minLength: 4)
|
||||
Menu {
|
||||
Button("Settings…") {
|
||||
(model as? SettingsWindowPresenting)?.presentSettingsWindow()
|
||||
}
|
||||
.keyboardShortcut(",", modifiers: .command)
|
||||
Button(model.isCheckingForUpdates ? "Checking for Updates…" : "Check for Updates…") {
|
||||
model.checkForUpdates()
|
||||
}
|
||||
.disabled(model.isCheckingForUpdates)
|
||||
if let update = model.updateAvailable {
|
||||
Button("Update to \(update.version)") { model.installUpdate() }
|
||||
}
|
||||
if let previous = model.previousVersion {
|
||||
Button("Revert to \(previous)") { model.revertToPreviousVersion() }
|
||||
}
|
||||
Divider()
|
||||
Button("Quit Redline") { NSApp.terminate(nil) }
|
||||
.keyboardShortcut("q", modifiers: .command)
|
||||
} label: {
|
||||
Image(systemName: "ellipsis.circle")
|
||||
}
|
||||
.menuStyle(.borderlessButton)
|
||||
.menuIndicator(.hidden)
|
||||
.fixedSize()
|
||||
.help("More Redline actions")
|
||||
.accessibilityLabel("More")
|
||||
}
|
||||
.overlay(alignment: .topTrailing) {
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
|
||||
private var sendChannel: String {
|
||||
model.transport == .oneDrive ? "Saves to OneDrive" : "Sends via AirDrop"
|
||||
}
|
||||
|
||||
// MARK: - Not granted
|
||||
// MARK: - Permission
|
||||
|
||||
private var permissionBlock: some View {
|
||||
HStack(alignment: .top, spacing: 6) {
|
||||
|
||||
Reference in New Issue
Block a user