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
23 changes: 23 additions & 0 deletions BetterCapture/Model/SettingsStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@

/// Container format for output files
enum ContainerFormat: String, CaseIterable, Identifiable {
case mov = "mov"

Check warning on line 75 in BetterCapture/Model/SettingsStore.swift

View workflow job for this annotation

GitHub Actions / Lint

String enum values can be omitted when they are equal to the enumcase name (redundant_string_enum_value)
case mp4 = "mp4"

Check warning on line 76 in BetterCapture/Model/SettingsStore.swift

View workflow job for this annotation

GitHub Actions / Lint

String enum values can be omitted when they are equal to the enumcase name (redundant_string_enum_value)

var id: String { rawValue }

Expand Down Expand Up @@ -199,7 +199,18 @@
/// Persists user preferences using AppStorage
@MainActor
@Observable
final class SettingsStore {

Check warning on line 202 in BetterCapture/Model/SettingsStore.swift

View workflow job for this annotation

GitHub Actions / Lint

Class body should span 300 lines or less excluding comments and whitespace: currently spans 380 lines (type_body_length)

Check warning on line 203 in BetterCapture/Model/SettingsStore.swift

View workflow job for this annotation

GitHub Actions / Lint

Lines should not have trailing whitespace (trailing_whitespace)
init() {
registerDefaultSettings()
}

Check warning on line 207 in BetterCapture/Model/SettingsStore.swift

View workflow job for this annotation

GitHub Actions / Lint

Lines should not have trailing whitespace (trailing_whitespace)
func registerDefaultSettings() {
// Add default values for settings here
UserDefaults.standard.register(defaults: [
"captureNativeResolution": true
])
}

// MARK: - Video Settings

Expand Down Expand Up @@ -313,6 +324,18 @@
}
}
}

Check warning on line 327 in BetterCapture/Model/SettingsStore.swift

View workflow job for this annotation

GitHub Actions / Lint

Lines should not have trailing whitespace (trailing_whitespace)
var captureNativeResolution: Bool {
get {
access(keyPath: \.captureNativeResolution)
return UserDefaults.standard.bool(forKey: "captureNativeResolution")
}
set {
withMutation(keyPath: \.captureNativeResolution) {
UserDefaults.standard.set(newValue, forKey: "captureNativeResolution")
}
}
}

// MARK: - Audio Settings

Expand Down Expand Up @@ -653,4 +676,4 @@
func generateOutputURL() -> URL {
outputDirectory.appending(path: generateFilename())
}
}

Check warning on line 679 in BetterCapture/Model/SettingsStore.swift

View workflow job for this annotation

GitHub Actions / Lint

File should contain 500 lines or less: currently contains 679 (file_length)
6 changes: 6 additions & 0 deletions BetterCapture/View/MenuBarSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,12 @@ struct VideoSettingsSection: View {
isOn: $settings.captureHDR,
isDisabled: !settings.videoCodec.supportsHDR
)

// Capture Native Resolution Toggle
MenuBarToggle(
name: "Capture Native Resolution",
isOn: $settings.captureNativeResolution
)
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions BetterCapture/View/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ struct VideoSettingsView: View {
return "ProRes codecs use fixed-quality encoding"
}
}

private let captureNativeResHelpText = "Choose between the Native resolution of your display or the Logical (1x) resolution"

var body: some View {
Form {
Expand Down Expand Up @@ -108,6 +110,9 @@ struct VideoSettingsView: View {
Toggle("HDR Recording", isOn: $settings.captureHDR)
.disabled(!settings.videoCodec.supportsHDR)
.help(hdrHelpText)

Toggle("Capture Native Resolution", isOn: $settings.captureNativeResolution)
.help(captureNativeResHelpText)
}

Section("Display Elements") {
Expand Down
16 changes: 11 additions & 5 deletions BetterCapture/ViewModel/RecorderViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,17 @@
// MARK: - Helper Methods

private func getContentSize(from filter: SCContentFilter) async -> CGSize {
// Apply scale if Capture Native Resolution setting is enabled
let applyScale: Bool = settings.captureNativeResolution

// If area selection is active, use the source rect dimensions.
// The sourceRect is already snapped to even pixel counts in presentAreaSelection().
if let sourceRect = selectedSourceRect {
let scale = CGFloat(filter.pointPixelScale)
return CGSize(width: sourceRect.width * scale, height: sourceRect.height * scale)
return CGSize(
width: applyScale ? sourceRect.width * scale : sourceRect.width,
height: applyScale ? sourceRect.height * scale : sourceRect.height
)
}

// Get the content rect from the filter
Expand All @@ -379,16 +385,16 @@

if rect.width > 0 && rect.height > 0 {
return CGSize(
width: rect.width * scale,
height: rect.height * scale
width: applyScale ? rect.width * scale : rect.width,

Check warning on line 388 in BetterCapture/ViewModel/RecorderViewModel.swift

View workflow job for this annotation

GitHub Actions / Lint

Colons should be next to the identifier when specifying a type and next to the key in dictionary literals (colon)
height: applyScale ? rect.height * scale: rect.height

Check warning on line 389 in BetterCapture/ViewModel/RecorderViewModel.swift

View workflow job for this annotation

GitHub Actions / Lint

Operators should be surrounded by a single whitespace when they are being used (operator_usage_whitespace)
)
}

// Fallback to main screen size
if let screen = NSScreen.main {
return CGSize(
width: screen.frame.width * screen.backingScaleFactor,
height: screen.frame.height * screen.backingScaleFactor
width: applyScale ? screen.frame.width * screen.backingScaleFactor : screen.frame.width,
height: applyScale ? screen.frame.height * screen.backingScaleFactor : screen.frame.height
)
}

Expand Down
Loading