Terminal.Gui icon indicating copy to clipboard operation
Terminal.Gui copied to clipboard

Partially Adresses #2491. Refactors how `Focus` works

Open tig opened this issue 6 months ago • 25 comments

This PR paves the way for fixing #2491 by addressing deep design and implementation problems with how Focus currently works.

This PR used to be way more ambitions... it was going to eventually fully enable any View to work Overlapped, removing the need for Toplevel and IsOverlappedContainer. That will now come later.

Fixes

  • New design and implementation for how Focus works.
  • Partially Addresses #2491
  • Fixes #3669
  • Fixes #3645

Proposed Changes/Todos

  • [x] Discovered serious issues with how HasFocus, OnEnter/OnLeave, etc... …work in some edge cases. This will require re-visiting the design at a deep level and fixing some long-standing but ignored issues such as how OnEnter/OnLeave don't follow proper cancelation design. Also, there's a need for keeping track of the old focus state of a tree of subviews when that tree loses focus; FocusDireciton is a hack that causes tons of confusion. See https://github.com/tig/Terminal.Gui/blob/8e70e2ae8faafab7cb8305ec6dbbd552c7bf3a43/docfx/docs/navigation.md
  • [x] Figure out how ViewArrangement.Overlapped will work. Use TabIndexes and all the View.NextView focus stuff for navigation (instead of the code in OverlappedMoveNext). Use the Subview ordering (for just the subviews with ViewArrangement.Overlapped` set) to manage the z-order.
  • [x] Rewrite focus engine
  • [x] Dozens of new, primitive unit tests
  • [x] Updated migration doc
  • [x] Massive code cleanup including making most of View #nullable enable
  • [x] View Experiments scenario -> Navigation Tester
  • [x] TabGroup navigation doesn't work completely right with nested groups. These are edge cases that I may tackle later.
  • [x] Fix TabView Scenario - above item may address
  • [ ] Fix Wizards - above item may address

Pull Request checklist:

  • [x] I've named my PR in the form of "Fixes #issue. Terse description."
  • [x] My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • [x] My code follows the Terminal.Gui library design guidelines
  • [x] I ran dotnet test before commit
  • [x] I have made corresponding changes to the API documentation (using /// style comments)
  • [x] My changes generate no new warnings
  • [x] I have checked my code and corrected any poor grammar or misspellings
  • [x] I conducted basic QA to assure all features are working

tig avatar Jul 25 '24 20:07 tig