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
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
4 changes: 4 additions & 0 deletions CodeEdit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@
B6AB09A12AAABAAE0003A3A6 /* EditorTabs.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6AB09A02AAABAAE0003A3A6 /* EditorTabs.swift */; };
B6AB09A32AAABFEC0003A3A6 /* EditorTabBarLeadingAccessories.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6AB09A22AAABFEC0003A3A6 /* EditorTabBarLeadingAccessories.swift */; };
B6AB09A52AAAC00F0003A3A6 /* EditorTabBarTrailingAccessories.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6AB09A42AAAC00F0003A3A6 /* EditorTabBarTrailingAccessories.swift */; };
B6AB09B32AB919CF0003A3A6 /* View+actionBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6AB09B22AB919CF0003A3A6 /* View+actionBar.swift */; };
B6C6A42A297716A500A3D28F /* EditorTabCloseButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6C6A429297716A500A3D28F /* EditorTabCloseButton.swift */; };
B6C6A42E29771A8D00A3D28F /* EditorTabButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6C6A42D29771A8D00A3D28F /* EditorTabButtonStyle.swift */; };
B6C6A43029771F7100A3D28F /* EditorTabBackground.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6C6A42F29771F7100A3D28F /* EditorTabBackground.swift */; };
Expand Down Expand Up @@ -816,6 +817,7 @@
B6AB09A02AAABAAE0003A3A6 /* EditorTabs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditorTabs.swift; sourceTree = "<group>"; };
B6AB09A22AAABFEC0003A3A6 /* EditorTabBarLeadingAccessories.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditorTabBarLeadingAccessories.swift; sourceTree = "<group>"; };
B6AB09A42AAAC00F0003A3A6 /* EditorTabBarTrailingAccessories.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditorTabBarTrailingAccessories.swift; sourceTree = "<group>"; };
B6AB09B22AB919CF0003A3A6 /* View+actionBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+actionBar.swift"; sourceTree = "<group>"; };
B6C6A429297716A500A3D28F /* EditorTabCloseButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditorTabCloseButton.swift; sourceTree = "<group>"; };
B6C6A42D29771A8D00A3D28F /* EditorTabButtonStyle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditorTabButtonStyle.swift; sourceTree = "<group>"; };
B6C6A42F29771F7100A3D28F /* EditorTabBackground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditorTabBackground.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2179,6 +2181,7 @@
children = (
B6CF632529E541520085880A /* Models */,
B61DA9DE29D929E100BF4A43 /* GeneralSettingsView.swift */,
B6AB09B22AB919CF0003A3A6 /* View+actionBar.swift */,
);
path = GeneralSettings;
sourceTree = "<group>";
Expand Down Expand Up @@ -3170,6 +3173,7 @@
B6AB09A12AAABAAE0003A3A6 /* EditorTabs.swift in Sources */,
04C3255B2801F86400C8DA2D /* ProjectNavigatorViewController.swift in Sources */,
587B9E6029301D8F00AC7927 /* GitLabOAuthRouter.swift in Sources */,
B6AB09B32AB919CF0003A3A6 /* View+actionBar.swift in Sources */,
6C05A8AF284D0CA3007F4EAA /* WorkspaceDocument+Listeners.swift in Sources */,
588847632992A2A200996D95 /* CEWorkspaceFile.swift in Sources */,
6C2C155D29B4F4E500EA60A5 /* SplitViewReader.swift in Sources */,
Expand Down
4 changes: 4 additions & 0 deletions CodeEdit/Features/Editor/Views/EditorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -30,6 +33,7 @@ struct EditorView: View {
: 0
)
}
.opacity(dimEditorsWithoutFocus && editor != editorManager.activeEditor ? 0.5 : 1)
} else {
VStack {
Spacer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct GeneralSettingsView: View {
fileIconStyle
tabBarStyle
showEditorPathBar
dimEditorsWithoutFocus
navigatorTabBarPosition
inspectorTabBarPosition
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -376,24 +381,3 @@ private extension GeneralSettingsView {
$0.timeStyle = .medium
}
}

extension View {
func actionBar<Content: View>(@ViewBuilder content: () -> Content) -> some View {
self
.padding(.bottom, 24)
.overlay(alignment: .bottom) {
VStack(spacing: -1) {
Divider()
HStack(spacing: 0) {
content()
.buttonStyle(.icon(font: Font.system(size: 11, weight: .medium), size: 24))
}
.frame(height: 16)
.padding(.vertical, 4)
.frame(maxWidth: .infinity, alignment: .leading)
}
.frame(height: 24)
.background(.separator)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// View+actionBar.swift
// CodeEdit
//
// Created by Austin Condiff on 9/18/23.
//

import SwiftUI

extension View {
func actionBar<Content: View>(@ViewBuilder content: () -> Content) -> some View {
self
.padding(.bottom, 24)
.overlay(alignment: .bottom) {
VStack(spacing: -1) {
Divider()
HStack(spacing: 0) {
content()
.buttonStyle(.icon(font: Font.system(size: 11, weight: .medium), size: 24))
}
.frame(height: 16)
.padding(.vertical, 4)
.frame(maxWidth: .infinity, alignment: .leading)
}
.frame(height: 24)
.background(.separator)
}
}
}
4 changes: 4 additions & 0 deletions CodeEdit/Features/WindowCommands/ViewCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ struct ViewCommands: Commands {
var useNewWindowingSystem
@AppSettings(\.general.showEditorPathBar)
var showEditorPathBar
@AppSettings(\.general.dimEditorsWithoutFocus)
var dimEditorsWithoutFocus

@State var windowController: CodeEditWindowController?

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

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

Divider()
}
}
Expand Down