Skip to content

Add tab.closeButton: activeOnly #13672

@zadjii-msft

Description

@zadjii-msft

TabView is a part of WinUI, and that code is available over at https://github.com/microsoft/microsoft-ui-xaml/

I want to know if it's even possible on the current version of TabView to actualize what that enum would represent?

Hm.

if (const auto theme = _settings.GlobalSettings().CurrentTheme())
{
const auto visibility = theme.Tab() ? theme.Tab().ShowCloseButton() : Settings::Model::TabCloseButtonVisibility::Always;
for (const auto& tab : _tabs)
{
switch (visibility)
{
case Settings::Model::TabCloseButtonVisibility::Never:
tab.TabViewItem().IsClosable(false);
break;
case Settings::Model::TabCloseButtonVisibility::Hover:
tab.TabViewItem().IsClosable(true);
break;
default:
tab.TabViewItem().IsClosable(true);
break;
}
}
switch (visibility)
{
case Settings::Model::TabCloseButtonVisibility::Never:
_tabView.CloseButtonOverlayMode(MUX::Controls::TabViewCloseButtonOverlayMode::Auto);
break;
case Settings::Model::TabCloseButtonVisibility::Hover:
_tabView.CloseButtonOverlayMode(MUX::Controls::TabViewCloseButtonOverlayMode::OnPointerOver);
break;
default:
_tabView.CloseButtonOverlayMode(MUX::Controls::TabViewCloseButtonOverlayMode::Always);
break;
}
}

Note

Walkthrough

  • We could take that, turn that into a method.
  • Call that method every time the active tab changes...
  • ... or the set of tabs changes.
  • Get rid of all the calls to _updateTabCloseButton, cause that only updates a single tab.
  • Add logic in that method
    • Inside the loop, if the mode is ActiveOnly, and the tab is active, then IsClosable(true). else false
    • Outside the loop, set CloseButtonOverlayMode to Auto, probably a sensible default.

That sounds like it would work on paper. Wanna file a PR? 😄

Originally posted by @zadjii-msft in #3335 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-ThemingAnything related to the theming of elements of the windowHelp WantedWe encourage anyone to jump in on these.In-PRThis issue has a related PRIssue-TaskIt's a feature request, but it doesn't really need a major design.Product-TerminalThe new Windows Terminal.good first issueThis is a fix that might be easier for someone to do as a first contribution

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions