Currently, interactions with the user interface, like changing providers, opening menus or even resizing windows, take the focus away from the main views. This PR resets focus to the child (if view has no children then the view's window itself is used) of the view that had focus before the interaction took place.
It was tested by interacting with menus, changing providers, using toolbar icons, using command palette, resizing windows or widgets of the view itself that are not children windows of the main view (e.g. running a pattern and having focus return to the pattern editor when evaluation ends. or using the icons in the hex editor) and also by selecting the main view itself. To clarify this last item, if you click on the view tab (not the provider tab but the view tab itself) the focus will be restored to the child that had focused before the tab was clicked
There is no attempt to recover the active status of widgets within the window but it can be easily recovered by clicking the Tab key once. Some views, like the pattern data view, can set other views to focus depending on where they are clicked.
The implementation saves the the child sub-window in a pointer of the view and is only changed if another child is given focus. Then various UI interactions are detected with care not to change focus while the interaction occurs. The end of the interaction is detected by checking if undesired items are the ones that have focus (these undesired values only occur when the UI interaction ends) and if they are, then the focus is restored to the window that is stored in the view pointer.
<!--
Please provide as much information as possible about what your PR aims
to do.
PRs with no description will most likely be closed until more
information is provided.
If you're planing on changing fundamental behaviour or add big new
features, please open a GitHub Issue first before starting to work on
it.
If it's not something big and you still want to contact us about it,
feel free to do so !
-->
### Problem description
<!-- Describe the bug that you fixed/feature request that you
implemented, or link to an existing issue describing it -->
### Implementation description
<!-- Explain what you did to correct the problem -->
### Screenshots
<!-- If your change is visual, take a screenshot showing it. Ideally,
make before/after sceenshots -->
### Additional things
<!-- Anything else you would like to say -->
This is a trivial change which adds virtual methods to View, `onOpen()`
and `onClose()`, which are called when the view is opened or closed.
This information is already tracked inside the View, but not exposed via
the API. There is `didWindowJustOpen()` and `didWindowJustClose()`, but
these fetch and then reset the flag, so they can't be used more than
once in a frame (and are sometimes called by the frame, meaning the flag
has already been consumed by the time the View's draw callback gets
called).
The use case here is that I have a View which needs to do some work
every time it's shown.
<!--
Please provide as much information as possible about what your PR aims
to do.
PRs with no description will most likely be closed until more
information is provided.
If you're planing on changing fundamental behaviour or add big new
features, please open a GitHub Issue first before starting to work on
it.
If it's not something big and you still want to contact us about it,
feel free to do so !
-->
### Problem description
<!-- Describe the bug that you fixed/feature request that you
implemented, or link to an existing issue describing it -->
Projects weren't being saved as recent when a new project was saved.
They were only added as recent when re-opening the project
### Implementation description
<!-- Explain what you did to correct the problem -->
I also save projects as recent when saving them (I don't make a
difference between saving existing and new projects)
### Screenshots
<!-- If your change is visual, take a screenshot showing it. Ideally,
make before/after sceenshots -->
### Additional things
<!-- Anything else you would like to say -->