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

Move the Close... actions to a nested menu on the tab #15250

Merged
merged 1 commit into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/cascadia/TerminalApp/TabBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ namespace winrt::TerminalApp::implementation
// Arguments:
// - flyout - the menu flyout to which the close items must be appended
// Return Value:
// - <none>
void TabBase::_AppendCloseMenuItems(winrt::Windows::UI::Xaml::Controls::MenuFlyout flyout)
// - the sub-item that we use for all the nested "close" entries. This
// enables subclasses to add their own entries to this menu.
winrt::Windows::UI::Xaml::Controls::MenuFlyoutSubItem TabBase::_AppendCloseMenuItems(winrt::Windows::UI::Xaml::Controls::MenuFlyout flyout)
{
auto weakThis{ get_weak() };

Expand Down Expand Up @@ -120,15 +121,16 @@ namespace winrt::TerminalApp::implementation
WUX::Controls::ToolTipService::SetToolTip(closeTabMenuItem, box_value(closeTabToolTip));
Automation::AutomationProperties::SetHelpText(closeTabMenuItem, closeTabToolTip);

// GH#8238 append the close menu items to the flyout itself until crash in XAML is fixed
//Controls::MenuFlyoutSubItem closeSubMenu;
//closeSubMenu.Text(RS_(L"TabCloseSubMenu"));
//closeSubMenu.Items().Append(_closeTabsAfterMenuItem);
//closeSubMenu.Items().Append(_closeOtherTabsMenuItem);
//flyout.Items().Append(closeSubMenu);
flyout.Items().Append(_closeTabsAfterMenuItem);
flyout.Items().Append(_closeOtherTabsMenuItem);
// Create a sub-menu for our extended close items.
Controls::MenuFlyoutSubItem closeSubMenu;
closeSubMenu.Text(RS_(L"TabCloseSubMenu"));
closeSubMenu.Items().Append(_closeTabsAfterMenuItem);
closeSubMenu.Items().Append(_closeOtherTabsMenuItem);
flyout.Items().Append(closeSubMenu);

flyout.Items().Append(closeTabMenuItem);

return closeSubMenu;
}

// Method Description:
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/TabBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace winrt::TerminalApp::implementation

virtual void _MakeTabViewItem();

void _AppendCloseMenuItems(winrt::Windows::UI::Xaml::Controls::MenuFlyout flyout);
winrt::Windows::UI::Xaml::Controls::MenuFlyoutSubItem _AppendCloseMenuItems(winrt::Windows::UI::Xaml::Controls::MenuFlyout flyout);
void _EnableCloseMenuItems();
void _CloseTabsAfter();
void _CloseOtherTabs();
Expand Down
6 changes: 4 additions & 2 deletions src/cascadia/TerminalApp/TerminalTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,7 @@ namespace winrt::TerminalApp::implementation
contextMenuFlyout.Items().Append(renameTabMenuItem);
contextMenuFlyout.Items().Append(duplicateTabMenuItem);
contextMenuFlyout.Items().Append(splitTabMenuItem);
contextMenuFlyout.Items().Append(closePaneMenuItem);

contextMenuFlyout.Items().Append(exportTabMenuItem);
contextMenuFlyout.Items().Append(findMenuItem);
contextMenuFlyout.Items().Append(menuSeparator);
Expand All @@ -1423,7 +1423,9 @@ namespace winrt::TerminalApp::implementation
}
}
});
_AppendCloseMenuItems(contextMenuFlyout);
auto closeSubMenu = _AppendCloseMenuItems(contextMenuFlyout);
Copy link
Member

Choose a reason for hiding this comment

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

I am a little bit weirded out by this returning a menu into which we then insert another thing, but also. whatever. that's cool :)

closeSubMenu.Items().Append(closePaneMenuItem);

TabViewItem().ContextFlyout(contextMenuFlyout);
}

Expand Down