Skip to content

Hide interface #2044

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Hide interface #2044

wants to merge 10 commits into from

Conversation

SimonKudsk
Copy link

@SimonKudsk SimonKudsk commented May 13, 2025

Description

A "Hide interface" button within view settings has been added. To facilitate this, multiple changes have been made:

  • Added file "CodeEditWindowController+Panels.swift" with logic for hiding panels
  • Moved logic for toggling first and last panel from CodeEditWindowController.swift to CodeEditWindowController+Panels.swift.
  • Added possibility for SplitViewItems, first panel and last panel to be collapsed without animation
  • Added a specific command for the utility drawer to be opened without animation
  • Added Swift and Objective C specific functions for last panel and first panel toggling
  • Added "previous" variables of panel states within CodeEditWindowController.swift

The behavior of the hide interface button differs, depending on the current state of the interface, as per the description of the issue. The button will switch between hiding and showing the interface.

When showing:

  • If no panels are open, and no previous values are stored, all panels will open when toggling.
  • If no panels are open, and previous values are stored, the previous panels will open.
  • If some panels are open, and previous values are stored, it will open the remaining panels.

When hiding:

  • Current state of the interface is stored, and all elements are hidden.

When individual interface elements are toggled, the button will also update. If all elements are manually enabled, the button will change back to "Hide interface".

Related Issues

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

Screen.Recording.2025-05-13.at.23.17.12.mov

SimonKudsk added 8 commits May 6, 2025 17:27
- Hide interface and shortcut will store the interface state and hide it
- Show interface will restore the interface state
- When hiding interface it will better be able to handle hidden elements being enabled, and then showing the interface again.
- Moved some logic from ViewCommands to CodeEditWindowController, as it seems like a more appropriate place.
- Added a bool shouldAnimate to function toggleFirstPanel. This is by default on, and thus using the default animation. When explicitly called with off, the function will not animate.
- Removed need for interfaceHidden bool
- Removed need for resetting stored interface state
- Added function isInterfaceStillHidden, checking whether "at least" the previous elements are visible again, taking other elements into account
- Hidden animation for lastpanel
- If no panels are active, and interface hasn't been hidden, all panels will show when toggle interface is clicked
- Renamed objc functions with prefix 'objc'
- Re-added resetStoredInterfaceCollapseState - turns out it was necessary
- Added command "open.drawer.no.animation" to command manager. This will toggle the utility area, without an animation.
- Added option possibility of no animation to SplitViewItem.Update
- Added struct SplitViewItemCanAnimateViewTraitKey and function splitViewCanAnimate to SplitViewModifiers. These optionally allow disabling animations for SplitViews.
- Updated "Hide Interface", WorkspaceView and UtilityAreaViewModel to accommodate these changes
- The logic for hide interface has been moved to a new file, CodeEditWindowsController+Panels.
- The function for toggling first panel and last panel has also been moved to said file.
- The logic for hide interface is now much more simplified, dynamic and easier to maintain.
- In isInterfaceStillHidden(), resetStoredInterfaceCollapseState() will now be called asynchronously to avoid a SwiftUI update warning
@austincondiff
Copy link
Collaborator

austincondiff commented May 14, 2025

Beautiful! Nice work! I look forward to reviewing your implementation. It’s definitely a feature I’ve been wanting to do for a while now and haven’t got around to. I’m glad you were able to knock it out.

It does look like we have a failed test, take a look when you get a chance.

@CodeEditApp/maintainers I wonder if we can default hide interface to true in single file mode and open it as a n empty workspace so users can open a folder, add tabs, etc similar to other editors. Any thoughts around this?

- Removed a comma that was causing the "Testing CodeEdit" task to fail
@SimonKudsk
Copy link
Author

I took a look at the failed test, and resolved the issue. I also added some UI tests. They are a bit lengthy, but they cover the logic the different conditions the hide interface button might encounter. I'd appreciate feedback on these, specifically their format, or if there is a better approach you'd recommend.

Please note that there is no single "hide interface" bool. This functionality depends on saving the state of the panels, hiding them all, and then using the stored states to restore. The logic required for defaulting to hiding the interface in single file mode is therefore not covered by this PR as is - that would likely require hiding the panels individually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants