-
-
Notifications
You must be signed in to change notification settings - Fork 1
fix: only allow alpha channel toggle when toggle is supported #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,25 +51,27 @@ struct MenuBarDivider: View { | |
| struct MenuBarToggle: View { | ||
| let name: String | ||
| @Binding var isOn: Bool | ||
| var isDisabled: Bool = false | ||
| @State private var isHovered = false | ||
|
|
||
| var body: some View { | ||
| HStack { | ||
| Text(name) | ||
| .font(.system(size: 13, weight: .medium)) | ||
| .foregroundStyle(.primary) | ||
| .foregroundStyle(isDisabled ? .secondary : .primary) | ||
| Spacer() | ||
| Toggle("", isOn: $isOn) | ||
| .toggleStyle(.switch) | ||
| .tint(.blue) | ||
| .scaleEffect(0.8) | ||
| .disabled(isDisabled) | ||
|
Comment on lines
59
to
+67
|
||
| } | ||
| .padding(.horizontal, 12) | ||
| .padding(.vertical, 4) | ||
| .contentShape(.rect) | ||
| .background( | ||
| RoundedRectangle(cornerRadius: 4) | ||
| .fill(isHovered ? .gray.opacity(0.1) : .clear) | ||
| .fill(isHovered && !isDisabled ? .gray.opacity(0.1) : .clear) | ||
| .padding(.horizontal, 4) | ||
| ) | ||
| .onHover { hovering in | ||
|
|
@@ -421,10 +423,12 @@ struct VideoSettingsSection: View { | |
| options: ContainerFormat.allCases.map { ($0, $0.rawValue.uppercased()) } | ||
| ) | ||
|
|
||
| // Alpha Channel Toggle (only for supported codecs) | ||
| if settings.videoCodec.supportsAlphaChannel { | ||
| MenuBarToggle(name: "Capture Alpha Channel", isOn: $settings.captureAlphaChannel) | ||
| } | ||
| // Alpha Channel Toggle (always visible, but disabled for non-toggleable codecs) | ||
| MenuBarToggle( | ||
| name: "Capture Alpha Channel", | ||
| isOn: $settings.captureAlphaChannel, | ||
| isDisabled: !settings.videoCodec.canToggleAlpha | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -34,6 +34,17 @@ struct SettingsView: View { | |||||||||||||||||||||
| struct VideoSettingsView: View { | ||||||||||||||||||||||
| @Bindable var settings: SettingsStore | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| private var alphaChannelHelpText: String { | ||||||||||||||||||||||
| switch settings.videoCodec { | ||||||||||||||||||||||
| case .proRes4444: | ||||||||||||||||||||||
| return "ProRes 4444 always includes alpha channel support" | ||||||||||||||||||||||
| case .hevc: | ||||||||||||||||||||||
| return "Enable transparency support for HEVC" | ||||||||||||||||||||||
| case .h264, .proRes422: | ||||||||||||||||||||||
| return "Alpha channel not supported by this codec" | ||||||||||||||||||||||
|
Comment on lines
+40
to
+44
|
||||||||||||||||||||||
| return "ProRes 4444 always includes alpha channel support" | |
| case .hevc: | |
| return "Enable transparency support for HEVC" | |
| case .h264, .proRes422: | |
| return "Alpha channel not supported by this codec" | |
| return "ProRes 4444 always includes an alpha channel." | |
| case .hevc: | |
| return "Enable transparency support for HEVC." | |
| case .h264, .proRes422: | |
| return "The alpha channel is not supported by this codec." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isDisabledis view input state and doesn’t appear to be mutated; preferlet isDisabled: Bool = falseto better communicate immutability and avoid accidental mutation in a value-typeView.