terminal/src/cascadia/TerminalApp/PaletteItemTemplateSelector.cpp
Don-Vito a3c8beaba0
Introduce zoom, bell and progress indicators to ATS (#9041)
## PR Checklist
* [x] Closes https://github.com/microsoft/terminal/issues/8912
* [x] CLA signed. 
* [ ] Tests added/passed
* [ ] Documentation updated.
* [ ] Schema updated.
* [ ] I've discussed this with core contributors already.

## Detailed Description of the Pull Request / Additional comments
* Introduced separate DataTemplate for rendering TabPaletteItem
* Introduced DataTemplateSelector assigning this template
* Introduced indicators as observable properties of the terminal Tab
* Bound TabPaletteItem to these properties
* Ensured that BindingUpdate is always called on CmdPal to avoid races
2021-02-08 17:37:58 +00:00

38 lines
1.6 KiB
C++

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include "pch.h"
#include "TabPaletteItem.h"
#include "PaletteItemTemplateSelector.h"
#include "PaletteItemTemplateSelector.g.cpp"
namespace winrt::TerminalApp::implementation
{
Windows::UI::Xaml::DataTemplate PaletteItemTemplateSelector::SelectTemplateCore(winrt::Windows::Foundation::IInspectable const& item, winrt::Windows::UI::Xaml::DependencyObject const& /*container*/)
{
return SelectTemplateCore(item);
}
// Method Description:
// - This method is called once command palette decides how to render a filtered command.
// Currently we support two ways to render command, that depend on its palette item type:
// - For TabPalette item we render an icon, a title, and some tab-related indicators like progress bar (as defined by TabItemTemplate)
// - All other items are currently rendered with icon, title and optional key-chord (as defined by GeneralItemTemplate)
// Arguments:
// - item - an instance of filtered command to render
// Return Value:
// - data template to use for rendering
Windows::UI::Xaml::DataTemplate PaletteItemTemplateSelector::SelectTemplateCore(winrt::Windows::Foundation::IInspectable const& item)
{
if (const auto filteredCommand{ item.try_as<winrt::TerminalApp::FilteredCommand>() })
{
if (filteredCommand.Item().try_as<winrt::TerminalApp::TabPaletteItem>())
{
return TabItemTemplate();
}
}
return GeneralItemTemplate();
}
}