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

Make Tab an unsealed runtimeclass (and rename it to TabBase) #8153

Merged
merged 1 commit into from
Nov 4, 2020

Conversation

DHowett
Copy link
Member

@DHowett DHowett commented Nov 3, 2020

In preparation for the Settings UI, we needed to make some changes to
Tab to abstract out shared functionality common between different types
of tab. This is the result of that work. All code references to the
settings have been removed or reverted.

Contains changes from #8053, #7802.

The messages below only make sense in the context of the Settings UI,
which this pull request does not bring in. They do, however, provide
valuable information.

From #7802 (@leonMSFT):

This PR's goal was to add an option to the OpenSettings keybinding to
open the Settings UI in a tab. In order to implement that, a couple of
changes had to be made to Tab, specifically:

  • Introduce a tab interface named ITab
  • Create/Rename two new Tab classes that implement ITab called
    SettingsTab and TerminalTab

From #8053:

TerminalTab and SettingsTab share some implementation details. The
close submenu introduced in #7728 is a good example of functionality
that is consistent across all tabs. This PR transforms ITab from an
interface, into an unsealed runtime class to de-duplicate some
functionality. Most of the logic from SettingsTab was moved there
because I expect the default behavior of a tab to resemble the
SettingsTab over a TerminalTab.

References

Verified that Close submenu work was transferred over (#7728, #7961, #8010).

Validation Steps Performed

Check close submenu on first/last tab when multiple tabs are open.

Closes #7969

Co-authored-by: Carlos Zamora carlos.zamora@microsoft.com

In preparation for the Settings UI, we needed to make some changes to
Tab to abstract out shared, common functionality between different types
of tab. This is the result of that work. All code references to the
settings have been removed or reverted.

Contains changes from #8053, #7802.

The messages below only make sense in the context of the Settings UI,
which this pull request does not bring in. They do, however, provide
valuable information.

From #7802 (@leonMSFT):

> This PR's goal was to add an option to the `OpenSettings` keybinding to
> open the Settings UI in a tab. In order to implement that, a couple of
> changes had to be made to `Tab`, specifically:
>
> - Introduce a tab interface named `ITab`
> - Create/Rename two new Tab classes that implement `ITab` called
>   `SettingsTab` and `TerminalTab`
>

From #8053:

> `TerminalTab` and `SettingsTab` share some implementation details. The
> close submenu introduced in #7728 is a good example of functionality
> that is consistent across all tabs. This PR transforms `ITab` from an
> interface, into an [unsealed runtime class] to de-duplicate some
> functionality. Most of the logic from `SettingsTab` was moved there
> because I expect the default behavior of a tab to resemble the
> `SettingsTab` over a `TerminalTab`.
>
> ## References
> Verified that Close submenu work was transferred over (#7728, #7961, #8010).
>
> ## Validation Steps Performed
> Check close submenu on first/last tab when multiple tabs are open.
>
> Closes #7969
>
> [unsealed runtime class]: https://docs.microsoft.com/en-us/uwp/midl-3/intro#base-classes

Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com>
@DHowett DHowett requested a review from zadjii-msft November 3, 2020 23:16
@ghost ghost added Area-UserInterface Issues pertaining to the user interface of the Console or Terminal Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-1 A description (P1) Product-Terminal The new Windows Terminal. labels Nov 3, 2020
@DHowett
Copy link
Member Author

DHowett commented Nov 3, 2020

I was one of the two signoffs on both of these pull requests, so I will merge this if @zadjii-msft, @miniksa or @PankajBhojwani sign off. Highly preferable that it's @zadjii-msft.

@carlos-zamora and @leonMSFT do not count.

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with this.

I think in the future, it'd be better to have it all be a uniform Tab with non-terminal panes, but we can work towards that from this. SUI is way higher priority now anyways.

Comment on lines 1557 to +1559
if (auto index{ _GetFocusedTabIndex() })
{
auto focusedTab{ _GetStrongTabImpl(*index) };
_UnZoomIfNeeded();
focusedTab->ResizePane(direction);
if (auto terminalTab = _GetTerminalTabImpl(_tabs.GetAt(*index)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of this if (get focused tab index) { if (get tab from index) { tab.doSomething() } } going on in here. Would it be better to have a helper that just does it all in one go?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d rather not add that now to reduce the merge burden when this flows back into SUI (since right now i can use the “take all ours” strategy), but it is worth doing.

[default_interface] runtimeclass Tab : Windows.UI.Xaml.Data.INotifyPropertyChanged
{
String Title { get; };
Windows.UI.Xaml.Controls.IconSource IconSource { get; };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So just as a sanity check, IconSource wasn't actually being used anywhere, was it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On account of it compiles and runs fine without IconSource, I am inclined to say yes.

@DHowett
Copy link
Member Author

DHowett commented Nov 4, 2020

@msftbot merge this in about 1 minute

@ghost ghost added the AutoMerge Marked for automatic merge by the bot when requirements are met label Nov 4, 2020
@ghost
Copy link

ghost commented Nov 4, 2020

Hello @DHowett!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I won't merge this pull request until after the UTC date Wed, 04 Nov 2020 17:20:25 GMT, which is in 1 minute

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

@DHowett
Copy link
Member Author

DHowett commented Nov 4, 2020

Oh right, bot don't merge single signoff PRs

@DHowett DHowett merged commit 4eeaddc into main Nov 4, 2020
@DHowett DHowett deleted the dev/duhowett/itab_interface branch November 4, 2020 18:15
@miniksa
Copy link
Member

miniksa commented Nov 4, 2020

lol I was just about to 2nd this.

ghost pushed a commit that referenced this pull request Nov 5, 2020
A fix for UTs crashing due to bad memory access (accessing page 0).
Regression from #8153
Closes #8167
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-UserInterface Issues pertaining to the user interface of the Console or Terminal AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-1 A description (P1) Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Close Menu, "Close other tabs" and "Close tabs to right" always operate on tab index 0, are always enabled
4 participants