Skip to content
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

Dim editors without focus #1423

Merged
Merged
Changes from 1 commit
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
Next Next commit
Provide users the option to dim editors without focus
austincondiff committed Sep 18, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit a339dbfbd6adb8dc75a93f94a543808de88f5b59
4 changes: 4 additions & 0 deletions CodeEdit/Features/Editor/Views/EditorView.swift
Original file line number Diff line number Diff line change
@@ -11,6 +11,9 @@ struct EditorView: View {
@AppSettings(\.general.showEditorPathBar)
var showEditorPathBar

@AppSettings(\.general.dimEditorsWithoutFocus)
var dimEditorsWithoutFocus

@ObservedObject var editor: Editor

@FocusState.Binding var focus: Editor?
@@ -30,6 +33,7 @@ struct EditorView: View {
: 0
)
}
.opacity(dimEditorsWithoutFocus && editor != editorManager.activeEditor ? 0.5 : 1)
} else {
VStack {
Spacer()
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@ struct GeneralSettingsView: View {
fileIconStyle
tabBarStyle
showEditorPathBar
dimEditorsWithoutFocus
navigatorTabBarPosition
inspectorTabBarPosition
}
@@ -108,6 +109,10 @@ private extension GeneralSettingsView {
Toggle("Show Path Bar", isOn: $settings.showEditorPathBar)
}

var dimEditorsWithoutFocus: some View {
Toggle("Dim editors without focus", isOn: $settings.dimEditorsWithoutFocus)
}

var fileExtensions: some View {
Group {
Picker("File Extensions", selection: $settings.fileExtensionsVisibility) {
Original file line number Diff line number Diff line change
@@ -24,6 +24,9 @@ extension SettingsData {
/// Show editor path bar
var showEditorPathBar: Bool = true

/// Dims editors without focus
var dimEditorsWithoutFocus: Bool = false

/// The show file extensions behavior of the app
var fileExtensionsVisibility: FileExtensionsVisibility = .showAll

@@ -89,6 +92,10 @@ extension SettingsData {
Bool.self,
forKey: .showEditorPathBar
) ?? true
self.dimEditorsWithoutFocus = try container.decodeIfPresent(
Bool.self,
forKey: .dimEditorsWithoutFocus
) ?? false
self.fileExtensionsVisibility = try container.decodeIfPresent(
FileExtensionsVisibility.self,
forKey: .fileExtensionsVisibility
4 changes: 4 additions & 0 deletions CodeEdit/Features/WindowCommands/ViewCommands.swift
Original file line number Diff line number Diff line change
@@ -16,6 +16,8 @@ struct ViewCommands: Commands {
var useNewWindowingSystem
@AppSettings(\.general.showEditorPathBar)
var showEditorPathBar
@AppSettings(\.general.dimEditorsWithoutFocus)
var dimEditorsWithoutFocus

@State var windowController: CodeEditWindowController?

@@ -119,6 +121,8 @@ struct ViewCommands: Commands {
showEditorPathBar.toggle()
}

Toggle("Dim editors without focus", isOn: $dimEditorsWithoutFocus)

Divider()
}
}