From 8a43a58baa5ae3dbebd49a35e90e8c0b1ae27749 Mon Sep 17 00:00:00 2001 From: Nish Date: Sat, 19 Oct 2024 23:04:44 -0500 Subject: [PATCH 1/2] Hide Interface - Added support At the moment this code, toggles navigator, inspector, utility, pathbar and toolbar area and handles all cases for each of them when using hide interface. --- .../WindowCommands/ViewCommands.swift | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/CodeEdit/Features/WindowCommands/ViewCommands.swift b/CodeEdit/Features/WindowCommands/ViewCommands.swift index c11aff90d..b596eb417 100644 --- a/CodeEdit/Features/WindowCommands/ViewCommands.swift +++ b/CodeEdit/Features/WindowCommands/ViewCommands.swift @@ -71,7 +71,7 @@ struct ViewCommands: Commands { Divider() - HideCommands() + HideCommands(showEditorPathBar: $showEditorPathBar) Divider() @@ -94,6 +94,7 @@ struct ViewCommands: Commands { extension ViewCommands { struct HideCommands: View { @UpdatingWindowController var windowController: CodeEditWindowController? + @Binding var showEditorPathBar: Bool var navigatorCollapsed: Bool { windowController?.navigatorCollapsed ?? true @@ -111,6 +112,18 @@ extension ViewCommands { windowController?.toolbarCollapsed ?? true } + private var labelForInterfaceToggle: String { + let shouldShow = navigatorCollapsed && inspectorCollapsed && + toolbarCollapsed && !showEditorPathBar + return "\(shouldShow ? "Show" : "Hide") Interface" + } + + private var isAnyPanelVisible: Bool { + return !navigatorCollapsed || !inspectorCollapsed || + !utilityAreaCollapsed || !toolbarCollapsed || + showEditorPathBar + } + var body: some View { Button("\(navigatorCollapsed ? "Show" : "Hide") Navigator") { windowController?.toggleFirstPanel() @@ -135,6 +148,39 @@ extension ViewCommands { } .disabled(windowController == nil) .keyboardShortcut("t", modifiers: [.option, .command]) + + Button(labelForInterfaceToggle) { + if isAnyPanelVisible { + if !navigatorCollapsed { + windowController?.toggleFirstPanel() + } + + if !inspectorCollapsed { + windowController?.toggleLastPanel() + } + + if !utilityAreaCollapsed { + CommandManager.shared.executeCommand("open.drawer") + } + + if !toolbarCollapsed { + windowController?.toggleToolbar() + } + + if showEditorPathBar { + showEditorPathBar.toggle() + } + + } else { + // If all are closed, you can choose to open them again + windowController?.toggleFirstPanel() + windowController?.toggleLastPanel() + windowController?.toggleToolbar() + showEditorPathBar.toggle() + } + } + .disabled(windowController == nil) + .keyboardShortcut(".", modifiers: [.command]) } } } From 9655bb35aec4ee7f02a197d6454001a215f8e223 Mon Sep 17 00:00:00 2001 From: Nish Date: Wed, 23 Oct 2024 21:54:04 -0500 Subject: [PATCH 2/2] Hide Interface - Fix - Naming --- CodeEdit/Features/WindowCommands/ViewCommands.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CodeEdit/Features/WindowCommands/ViewCommands.swift b/CodeEdit/Features/WindowCommands/ViewCommands.swift index b596eb417..078318bbd 100644 --- a/CodeEdit/Features/WindowCommands/ViewCommands.swift +++ b/CodeEdit/Features/WindowCommands/ViewCommands.swift @@ -112,7 +112,7 @@ extension ViewCommands { windowController?.toolbarCollapsed ?? true } - private var labelForInterfaceToggle: String { + private var interfaceToggleLabel: String { let shouldShow = navigatorCollapsed && inspectorCollapsed && toolbarCollapsed && !showEditorPathBar return "\(shouldShow ? "Show" : "Hide") Interface" @@ -149,7 +149,7 @@ extension ViewCommands { .disabled(windowController == nil) .keyboardShortcut("t", modifiers: [.option, .command]) - Button(labelForInterfaceToggle) { + Button(interfaceToggleLabel) { if isAnyPanelVisible { if !navigatorCollapsed { windowController?.toggleFirstPanel()