mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-11 22:48:41 -06:00
Upgrade to Microsoft.UI.Xaml 2.2 (#3027)
* We had to move to the final API: * Items -> TabItems * Items.VectorChanged -> TabItemsChanged * TabClose -> TabCloseRequested * TabViewItem.Icon -> TabViewItem.IconSource * TabRowControl has been converted to a ContentPresenter, which simplifies its logic a little bit. * TerminalPage now differentiates MUX and WUX a little better * Because of the change from Icon to IconSource in TabViewItem, Utils::GetColoredIcon needed to be augmented to support MUX IconSources. It was still necessary to use for WUX, so it's been templatized. * I moved us from WUX SplitButton to MUX SplitButton and brought the style in line with the one typically provided by TabView. * Some of our local controls have had their backgrounds removed so they're more amenable to being placed on other surfaces. * I'm suppressing the TabView's padding. * I removed a number of apparently dead methods from App. * I've simplified the dragbar's sizing logic and eventing. * The winmd harvester needed to be taught to not try to copy winmds for framework packages. * We now only initialize the terminal once we know the size Closes #1896. Closes #444. Closes #857. Closes #771. Closes #760.
This commit is contained in:
parent
5d17557edf
commit
df26c677ef
@ -10,7 +10,7 @@
|
||||
<Target Name="_ConsoleMapWinmdsToManifestFiles" DependsOnTargets="ResolveAssemblyReferences">
|
||||
<ItemGroup>
|
||||
<!-- For each non-system .winmd file in References, generate a .manifest in IntDir for it. -->
|
||||
<_ConsoleWinmdManifest Include="@(ReferencePath->'$(IntDir)\%(FileName).manifest')" Condition="'%(ReferencePath.IsSystemReference)' != 'true' and '%(ReferencePath.WinMDFile)' == 'true' and '%(ReferencePath.ReferenceSourceTarget)' == 'ResolveAssemblyReference'">
|
||||
<_ConsoleWinmdManifest Include="@(ReferencePath->'$(IntDir)\%(FileName).manifest')" Condition="'%(ReferencePath.IsSystemReference)' != 'true' and '%(ReferencePath.WinMDFile)' == 'true' and '%(ReferencePath.ReferenceSourceTarget)' == 'ResolveAssemblyReference' and '%(ReferencePath.Implementation)' != ''">
|
||||
<WinMDPath>%(ReferencePath.FullPath)</WinMDPath>
|
||||
<Implementation>%(ReferencePath.Implementation)</Implementation>
|
||||
</_ConsoleWinmdManifest>
|
||||
|
||||
@ -339,4 +339,13 @@
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<!-- This is required to get the package dependency in the AppXManifest. -->
|
||||
<Import Project="..\..\..\packages\Microsoft.UI.Xaml.2.2.190917002\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\..\packages\Microsoft.UI.Xaml.2.2.190917002\build\native\Microsoft.UI.Xaml.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\..\packages\Microsoft.UI.Xaml.2.2.190917002\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.UI.Xaml.2.2.190917002\build\native\Microsoft.UI.Xaml.targets'))" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -90,11 +90,11 @@
|
||||
<!-- From Microsoft.UI.Xaml.targets -->
|
||||
<Native-Platform Condition="'$(Platform)' == 'Win32'">x86</Native-Platform>
|
||||
<Native-Platform Condition="'$(Platform)' != 'Win32'">$(Platform)</Native-Platform>
|
||||
<_MUXBinRoot>"$(OpenConsoleDir)packages\Microsoft.UI.Xaml.2.2.190611001-prerelease\runtimes\win10-$(Native-Platform)\native\"</_MUXBinRoot>
|
||||
<_MUXBinRoot>"$(OpenConsoleDir)packages\Microsoft.UI.Xaml.2.2.190917002\runtimes\win10-$(Native-Platform)\native\"</_MUXBinRoot>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- We actually can just straight up reference MUX here, it's fine -->
|
||||
<Import Project="..\..\..\packages\Microsoft.UI.Xaml.2.2.190611001-prerelease\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\..\packages\Microsoft.UI.Xaml.2.2.190611001-prerelease\build\native\Microsoft.UI.Xaml.targets')" />
|
||||
<Import Project="..\..\..\packages\Microsoft.UI.Xaml.2.2.190917002\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\..\packages\Microsoft.UI.Xaml.2.2.190917002\build\native\Microsoft.UI.Xaml.targets')" />
|
||||
<Import Project="..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.0.0-preview6.2\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets" Condition="Exists('..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.0.0-preview6.2\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets')" />
|
||||
|
||||
<!-- This project will generate individual sxs manifests for each of our winrt libraries -->
|
||||
|
||||
@ -76,21 +76,11 @@ namespace winrt::TerminalApp::implementation
|
||||
void _OnLoaded(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);
|
||||
|
||||
[[nodiscard]] HRESULT _TryLoadSettings() noexcept;
|
||||
void _LoadSettings();
|
||||
void _RegisterSettingsChange();
|
||||
fire_and_forget _DispatchReloadSettings();
|
||||
void _ReloadSettings();
|
||||
|
||||
void _ApplyTheme(const Windows::UI::Xaml::ElementTheme& newTheme);
|
||||
|
||||
static Windows::UI::Xaml::Controls::IconElement _GetIconFromProfile(const ::TerminalApp::Profile& profile);
|
||||
|
||||
winrt::Microsoft::Terminal::TerminalControl::TermControl _GetFocusedControl();
|
||||
|
||||
void _CopyToClipboardHandler(const IInspectable& sender, const winrt::Microsoft::Terminal::TerminalControl::CopyToClipboardEventArgs& copiedData);
|
||||
void _PasteFromClipboardHandler(const IInspectable& sender, const Microsoft::Terminal::TerminalControl::PasteFromClipboardEventArgs& eventArgs);
|
||||
|
||||
static void _SetAcceleratorForMenuItem(Windows::UI::Xaml::Controls::MenuFlyoutItem& menuItem, const winrt::Microsoft::Terminal::Settings::KeyChord& keyChord);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -49,13 +49,24 @@ the MIT License. See LICENSE in the project root for license information. -->
|
||||
is unfortunately static. -->
|
||||
<SolidColorBrush x:Name="ErrorTextBrush" Color="{ThemeResource SystemErrorTextColor}" />
|
||||
|
||||
<!-- Suppress all padding around the tabs. The TabView looks far better like this. -->
|
||||
<Thickness x:Key="TabViewHeaderPadding">0,0,0,0</Thickness>
|
||||
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary x:Key="Dark">
|
||||
<!-- Define resources for Dark mode here -->
|
||||
<!-- The TabViewBackground is used on a control (DragBar, TitleBarControl) whose color is propagated to GDI.
|
||||
The default background is black or white with an alpha component, as it's intended to be layered on top of
|
||||
another control. Unfortunately, GDI cannot handle this: we need to either render the XAML to a surface and
|
||||
sample the pixels out of it, or premultiply the alpha into the background. For obvious reasons, we've chosen
|
||||
the latter. -->
|
||||
<SolidColorBrush x:Key="TabViewBackground" Color="#FF333333" />
|
||||
</ResourceDictionary>
|
||||
|
||||
<ResourceDictionary x:Key="Light">
|
||||
<!-- Define resources for Light mode here -->
|
||||
<!-- See note about premultiplication above. -->
|
||||
<SolidColorBrush x:Key="TabViewBackground" Color="#FFCCCCCC" />
|
||||
</ResourceDictionary>
|
||||
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
|
||||
@ -8,7 +8,7 @@ the MIT License. See LICENSE in the project root for license information. -->
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource SystemChromeLowColor}"
|
||||
Background="Transparent"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
Orientation="Horizontal"
|
||||
|
||||
@ -10,7 +10,10 @@ using namespace winrt::Windows::UI::Core;
|
||||
using namespace winrt::Microsoft::Terminal::Settings;
|
||||
using namespace winrt::Microsoft::Terminal::TerminalControl;
|
||||
|
||||
static const int TabViewFontSize = 12;
|
||||
namespace winrt
|
||||
{
|
||||
namespace MUX = Microsoft::UI::Xaml;
|
||||
}
|
||||
|
||||
Tab::Tab(const GUID& profile, const TermControl& control)
|
||||
{
|
||||
@ -25,8 +28,7 @@ Tab::Tab(const GUID& profile, const TermControl& control)
|
||||
|
||||
void Tab::_MakeTabViewItem()
|
||||
{
|
||||
_tabViewItem = ::winrt::Microsoft::UI::Xaml::Controls::TabViewItem{};
|
||||
_tabViewItem.FontSize(TabViewFontSize);
|
||||
_tabViewItem = ::winrt::MUX::Controls::TabViewItem{};
|
||||
}
|
||||
|
||||
UIElement Tab::GetRootElement()
|
||||
@ -50,7 +52,7 @@ TermControl Tab::GetFocusedTerminalControl()
|
||||
return _rootPane->GetFocusedTerminalControl();
|
||||
}
|
||||
|
||||
winrt::Microsoft::UI::Xaml::Controls::TabViewItem Tab::GetTabViewItem()
|
||||
winrt::MUX::Controls::TabViewItem Tab::GetTabViewItem()
|
||||
{
|
||||
return _tabViewItem;
|
||||
}
|
||||
@ -154,7 +156,7 @@ void Tab::UpdateIcon(const winrt::hstring iconPath)
|
||||
_lastIconPath = iconPath;
|
||||
|
||||
_tabViewItem.Dispatcher().RunAsync(CoreDispatcherPriority::Normal, [this]() {
|
||||
_tabViewItem.Icon(GetColoredIcon(_lastIconPath));
|
||||
_tabViewItem.IconSource(GetColoredIcon<winrt::MUX::Controls::IconSource>(_lastIconPath));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
#include "TabRowControl.g.cpp"
|
||||
|
||||
using namespace winrt;
|
||||
using namespace Windows::UI::Xaml;
|
||||
using namespace winrt::Microsoft::UI::Xaml;
|
||||
|
||||
namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
|
||||
@ -13,7 +13,7 @@ namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
TabRowControl();
|
||||
|
||||
void OnNewTabButtonClick(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::Controls::SplitButtonClickEventArgs const& args);
|
||||
void OnNewTabButtonClick(Windows::Foundation::IInspectable const& sender, Microsoft::UI::Xaml::Controls::SplitButtonClickEventArgs const& args);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -3,10 +3,9 @@
|
||||
|
||||
namespace TerminalApp
|
||||
{
|
||||
[default_interface] runtimeclass TabRowControl : Windows.UI.Xaml.Controls.Grid
|
||||
[default_interface] runtimeclass TabRowControl : Windows.UI.Xaml.Controls.ContentPresenter
|
||||
{
|
||||
TabRowControl();
|
||||
Windows.UI.Xaml.Controls.SplitButton NewTabButton { get; };
|
||||
Microsoft.UI.Xaml.Controls.TabView TabView { get; };
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under
|
||||
the MIT License. See LICENSE in the project root for license information. -->
|
||||
<Grid
|
||||
<ContentPresenter
|
||||
x:Class="TerminalApp.TabRowControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
@ -10,22 +10,61 @@ the MIT License. See LICENSE in the project root for license information. -->
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<mux:TabView x:Name="TabView" VerticalAlignment="Bottom">
|
||||
<mux:TabView x:Name="TabView"
|
||||
VerticalAlignment="Bottom"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
IsAddTabButtonVisible="false"
|
||||
TabWidthMode="SizeToContent"
|
||||
CanReorderTabs="False"
|
||||
CanDragTabs="False"
|
||||
AllowDropTabs="False">
|
||||
|
||||
<mux:TabView.RightCustomContent>
|
||||
<SplitButton
|
||||
<mux:TabView.TabStripFooter>
|
||||
<mux:SplitButton
|
||||
x:Name="NewTabButton"
|
||||
Click="OnNewTabButtonClick"
|
||||
Background="{ThemeResource SystemChromeLowColor}"
|
||||
VerticalAlignment="Stretch"
|
||||
HorizontalAlignment="Left">
|
||||
<Viewbox MaxHeight="13"
|
||||
MaxWidth="13">
|
||||
<SymbolIcon Symbol="Add" />
|
||||
</Viewbox>
|
||||
</SplitButton>
|
||||
</mux:TabView.RightCustomContent>
|
||||
HorizontalAlignment="Left"
|
||||
Content=""
|
||||
UseLayoutRounding="true"
|
||||
FontFamily="Segoe MDL2 Assets"
|
||||
FontWeight="SemiLight"
|
||||
FontSize="12">
|
||||
<!-- U+E710 is the fancy plus icon. -->
|
||||
<mux:SplitButton.Resources>
|
||||
<!-- Override the SplitButton* resources to match the tab view's button's styles. -->
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary x:Key="Light">
|
||||
<StaticResource x:Key="SplitButtonBackground" ResourceKey="TabViewItemHeaderBackground" />
|
||||
<StaticResource x:Key="SplitButtonForeground" ResourceKey="SystemControlBackgroundBaseMediumBrush" />
|
||||
<StaticResource x:Key="SplitButtonBackgroundPressed" ResourceKey="TabViewItemHeaderBackgroundPressed" />
|
||||
<StaticResource x:Key="SplitButtonForegroundPressed" ResourceKey="SystemControlBackgroundBaseMediumHighBrush" />
|
||||
<StaticResource x:Key="SplitButtonBackgroundPointerOver" ResourceKey="TabViewItemHeaderBackgroundPointerOver" />
|
||||
<StaticResource x:Key="SplitButtonForegroundPointerOver" ResourceKey="SystemControlBackgroundBaseMediumHighBrush" />
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="Dark">
|
||||
<StaticResource x:Key="SplitButtonBackground" ResourceKey="TabViewItemHeaderBackground" />
|
||||
<StaticResource x:Key="SplitButtonForeground" ResourceKey="SystemControlBackgroundBaseMediumBrush" />
|
||||
<StaticResource x:Key="SplitButtonBackgroundPressed" ResourceKey="TabViewItemHeaderBackgroundPressed" />
|
||||
<StaticResource x:Key="SplitButtonForegroundPressed" ResourceKey="SystemControlBackgroundBaseMediumHighBrush" />
|
||||
<StaticResource x:Key="SplitButtonBackgroundPointerOver" ResourceKey="TabViewItemHeaderBackgroundPointerOver" />
|
||||
<StaticResource x:Key="SplitButtonForegroundPointerOver" ResourceKey="SystemControlBackgroundBaseMediumHighBrush" />
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="HighContrast">
|
||||
<StaticResource x:Key="SplitButtonBackground" ResourceKey="TabViewItemHeaderBackground" />
|
||||
<StaticResource x:Key="SplitButtonForeground" ResourceKey="SystemControlBackgroundBaseMediumBrush" />
|
||||
<StaticResource x:Key="SplitButtonBackgroundPressed" ResourceKey="TabViewItemHeaderBackgroundPressed" />
|
||||
<StaticResource x:Key="SplitButtonForegroundPressed" ResourceKey="SystemControlBackgroundBaseMediumHighBrush" />
|
||||
<StaticResource x:Key="SplitButtonBackgroundPointerOver" ResourceKey="TabViewItemHeaderBackgroundPointerOver" />
|
||||
<StaticResource x:Key="SplitButtonForegroundPointerOver" ResourceKey="SystemControlBackgroundBaseMediumHighBrush" />
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
</ResourceDictionary>
|
||||
</mux:SplitButton.Resources>
|
||||
</mux:SplitButton>
|
||||
</mux:TabView.TabStripFooter>
|
||||
|
||||
</mux:TabView>
|
||||
|
||||
</Grid>
|
||||
</ContentPresenter>
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
#include <winrt/Microsoft.UI.Xaml.XamlTypeInfo.h>
|
||||
|
||||
#include "AzureCloudShellGenerator.h" // For AzureConnectionType
|
||||
#include "TabRowControl.h"
|
||||
|
||||
using namespace winrt;
|
||||
using namespace winrt::Windows::UI::Xaml;
|
||||
@ -25,6 +26,7 @@ using namespace ::TerminalApp;
|
||||
namespace winrt
|
||||
{
|
||||
namespace MUX = Microsoft::UI::Xaml;
|
||||
namespace WUX = Windows::UI::Xaml;
|
||||
using IInspectable = Windows::Foundation::IInspectable;
|
||||
}
|
||||
|
||||
@ -57,7 +59,9 @@ namespace winrt::TerminalApp::implementation
|
||||
_tabContent = this->TabContent();
|
||||
_tabRow = this->TabRow();
|
||||
_tabView = _tabRow.TabView();
|
||||
_newTabButton = _tabRow.NewTabButton();
|
||||
|
||||
auto tabRowImpl = winrt::get_self<implementation::TabRowControl>(_tabRow);
|
||||
_newTabButton = tabRowImpl->NewTabButton();
|
||||
|
||||
if (_settings->GlobalSettings().GetShowTabsInTitlebar())
|
||||
{
|
||||
@ -78,8 +82,8 @@ namespace winrt::TerminalApp::implementation
|
||||
this->_OpenNewTab(std::nullopt);
|
||||
});
|
||||
_tabView.SelectionChanged({ this, &TerminalPage::_OnTabSelectionChanged });
|
||||
_tabView.Items().VectorChanged({ this, &TerminalPage::_OnTabItemsChanged });
|
||||
_tabView.TabClosing({ this, &TerminalPage::_OnTabClosing });
|
||||
_tabView.TabCloseRequested({ this, &TerminalPage::_OnTabCloseRequested });
|
||||
_tabView.TabItemsChanged({ this, &TerminalPage::_OnTabItemsChanged });
|
||||
|
||||
_CreateNewTabFlyout();
|
||||
_OpenNewTab(std::nullopt);
|
||||
@ -102,7 +106,7 @@ namespace winrt::TerminalApp::implementation
|
||||
auto message = _resourceLoader->GetLocalizedString(contentKey);
|
||||
auto buttonText = _resourceLoader->GetLocalizedString(L"Ok");
|
||||
|
||||
Controls::ContentDialog dialog;
|
||||
WUX::Controls::ContentDialog dialog;
|
||||
dialog.Title(winrt::box_value(title));
|
||||
dialog.Content(winrt::box_value(message));
|
||||
dialog.CloseButtonText(buttonText);
|
||||
@ -169,14 +173,14 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
const auto buttonText = _resourceLoader->GetLocalizedString(L"Ok");
|
||||
|
||||
Controls::TextBlock aboutTextBlock;
|
||||
WUX::Controls::TextBlock aboutTextBlock;
|
||||
aboutTextBlock.Inlines().Append(about);
|
||||
aboutTextBlock.Inlines().Append(gettingStartedLink);
|
||||
aboutTextBlock.Inlines().Append(documentationLink);
|
||||
aboutTextBlock.Inlines().Append(releaseNotesLink);
|
||||
aboutTextBlock.IsTextSelectionEnabled(true);
|
||||
|
||||
Controls::ContentDialog dialog;
|
||||
WUX::Controls::ContentDialog dialog;
|
||||
dialog.Title(winrt::box_value(title));
|
||||
dialog.Content(aboutTextBlock);
|
||||
dialog.CloseButtonText(buttonText);
|
||||
@ -197,7 +201,7 @@ namespace winrt::TerminalApp::implementation
|
||||
auto primaryButtonText = _resourceLoader->GetLocalizedString(L"CloseAll");
|
||||
auto secondaryButtonText = _resourceLoader->GetLocalizedString(L"Cancel");
|
||||
|
||||
Controls::ContentDialog dialog;
|
||||
WUX::Controls::ContentDialog dialog;
|
||||
dialog.Title(winrt::box_value(title));
|
||||
|
||||
dialog.PrimaryButtonText(primaryButtonText);
|
||||
@ -215,7 +219,7 @@ namespace winrt::TerminalApp::implementation
|
||||
// Below the profiles are the static menu items: settings, feedback
|
||||
void TerminalPage::_CreateNewTabFlyout()
|
||||
{
|
||||
auto newTabFlyout = Controls::MenuFlyout{};
|
||||
auto newTabFlyout = WUX::Controls::MenuFlyout{};
|
||||
auto keyBindings = _settings->GetKeybindings();
|
||||
|
||||
const GUID defaultProfileGuid = _settings->GlobalSettings().GetDefaultProfile();
|
||||
@ -224,7 +228,7 @@ namespace winrt::TerminalApp::implementation
|
||||
for (int profileIndex = 0; profileIndex < profileCount; profileIndex++)
|
||||
{
|
||||
const auto& profile = _settings->GetProfiles()[profileIndex];
|
||||
auto profileMenuItem = Controls::MenuFlyoutItem{};
|
||||
auto profileMenuItem = WUX::Controls::MenuFlyoutItem{};
|
||||
|
||||
// add the keyboard shortcuts for the first 9 profiles
|
||||
if (profileIndex < 9)
|
||||
@ -248,7 +252,11 @@ namespace winrt::TerminalApp::implementation
|
||||
// this flyout item.
|
||||
if (profile.HasIcon())
|
||||
{
|
||||
profileMenuItem.Icon(_GetIconFromProfile(profile));
|
||||
auto iconSource = GetColoredIcon<WUX::Controls::IconSource>(profile.GetExpandedIconPath());
|
||||
|
||||
WUX::Controls::IconSourceElement iconElement;
|
||||
iconElement.IconSource(iconSource);
|
||||
profileMenuItem.Icon(iconElement);
|
||||
}
|
||||
|
||||
if (profile.GetGuid() == defaultProfileGuid)
|
||||
@ -264,17 +272,17 @@ namespace winrt::TerminalApp::implementation
|
||||
}
|
||||
|
||||
// add menu separator
|
||||
auto separatorItem = Controls::MenuFlyoutSeparator{};
|
||||
auto separatorItem = WUX::Controls::MenuFlyoutSeparator{};
|
||||
newTabFlyout.Items().Append(separatorItem);
|
||||
|
||||
// add static items
|
||||
{
|
||||
// Create the settings button.
|
||||
auto settingsItem = Controls::MenuFlyoutItem{};
|
||||
auto settingsItem = WUX::Controls::MenuFlyoutItem{};
|
||||
settingsItem.Text(_resourceLoader->GetLocalizedString(L"SettingsMenuItem"));
|
||||
|
||||
Controls::SymbolIcon ico{};
|
||||
ico.Symbol(Controls::Symbol::Setting);
|
||||
WUX::Controls::SymbolIcon ico{};
|
||||
ico.Symbol(WUX::Controls::Symbol::Setting);
|
||||
settingsItem.Icon(ico);
|
||||
|
||||
settingsItem.Click({ this, &TerminalPage::_SettingsButtonOnClick });
|
||||
@ -287,24 +295,24 @@ namespace winrt::TerminalApp::implementation
|
||||
}
|
||||
|
||||
// Create the feedback button.
|
||||
auto feedbackFlyout = Controls::MenuFlyoutItem{};
|
||||
auto feedbackFlyout = WUX::Controls::MenuFlyoutItem{};
|
||||
feedbackFlyout.Text(_resourceLoader->GetLocalizedString(L"FeedbackMenuItem"));
|
||||
|
||||
Controls::FontIcon feedbackIco{};
|
||||
feedbackIco.Glyph(L"\xE939");
|
||||
feedbackIco.FontFamily(Media::FontFamily{ L"Segoe MDL2 Assets" });
|
||||
feedbackFlyout.Icon(feedbackIco);
|
||||
WUX::Controls::FontIcon feedbackIcon{};
|
||||
feedbackIcon.Glyph(L"\xE939");
|
||||
feedbackIcon.FontFamily(Media::FontFamily{ L"Segoe MDL2 Assets" });
|
||||
feedbackFlyout.Icon(feedbackIcon);
|
||||
|
||||
feedbackFlyout.Click({ this, &TerminalPage::_FeedbackButtonOnClick });
|
||||
newTabFlyout.Items().Append(feedbackFlyout);
|
||||
|
||||
// Create the about button.
|
||||
auto aboutFlyout = Controls::MenuFlyoutItem{};
|
||||
auto aboutFlyout = WUX::Controls::MenuFlyoutItem{};
|
||||
aboutFlyout.Text(_resourceLoader->GetLocalizedString(L"AboutMenuItem"));
|
||||
|
||||
Controls::SymbolIcon aboutIco{};
|
||||
aboutIco.Symbol(Controls::Symbol::Help);
|
||||
aboutFlyout.Icon(aboutIco);
|
||||
WUX::Controls::SymbolIcon aboutIcon{};
|
||||
aboutIcon.Symbol(WUX::Controls::Symbol::Help);
|
||||
aboutFlyout.Icon(aboutIcon);
|
||||
|
||||
aboutFlyout.Click({ this, &TerminalPage::_AboutButtonOnClick });
|
||||
newTabFlyout.Items().Append(aboutFlyout);
|
||||
@ -319,8 +327,8 @@ namespace winrt::TerminalApp::implementation
|
||||
// Shows the dropdown flyout.
|
||||
void TerminalPage::_OpenNewTabDropdown()
|
||||
{
|
||||
Controls::Primitives::FlyoutShowOptions options{};
|
||||
options.Placement(Controls::Primitives::FlyoutPlacementMode::BottomEdgeAlignedLeft);
|
||||
WUX::Controls::Primitives::FlyoutShowOptions options{};
|
||||
options.Placement(WUX::Controls::Primitives::FlyoutPlacementMode::BottomEdgeAlignedLeft);
|
||||
_newTabButton.Flyout().ShowAt(_newTabButton, options);
|
||||
}
|
||||
|
||||
@ -396,7 +404,7 @@ namespace winrt::TerminalApp::implementation
|
||||
_RegisterTerminalEvents(term, newTab);
|
||||
|
||||
auto tabViewItem = newTab->GetTabViewItem();
|
||||
_tabView.Items().Append(tabViewItem);
|
||||
_tabView.TabItems().Append(tabViewItem);
|
||||
|
||||
// Set this profile's tab to the icon the user specified
|
||||
if (profile != nullptr && profile->HasIcon())
|
||||
@ -632,10 +640,10 @@ namespace winrt::TerminalApp::implementation
|
||||
// and call _RemoveTabViewItemByIndex
|
||||
// Arguments:
|
||||
// - tabViewItem: the TabViewItem in the TabView that is being removed.
|
||||
void TerminalPage::_RemoveTabViewItem(const IInspectable& tabViewItem)
|
||||
void TerminalPage::_RemoveTabViewItem(const MUX::Controls::TabViewItem& tabViewItem)
|
||||
{
|
||||
uint32_t tabIndexFromControl = 0;
|
||||
_tabView.Items().IndexOf(tabViewItem, tabIndexFromControl);
|
||||
_tabView.TabItems().IndexOf(tabViewItem, tabIndexFromControl);
|
||||
|
||||
_RemoveTabViewItemByIndex(tabIndexFromControl);
|
||||
}
|
||||
@ -654,7 +662,7 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
// Removing the tab from the collection will destroy its control and disconnect its connection.
|
||||
_tabs.erase(_tabs.begin() + tabIndex);
|
||||
_tabView.Items().RemoveAt(tabIndex);
|
||||
_tabView.TabItems().RemoveAt(tabIndex);
|
||||
|
||||
auto focusedTabIndex = _GetFocusedTabIndex();
|
||||
if (tabIndex == focusedTabIndex)
|
||||
@ -785,7 +793,7 @@ namespace winrt::TerminalApp::implementation
|
||||
// GH#1117: This is a workaround because _tabView.SelectedIndex()
|
||||
// sometimes return incorrect result after removing some tabs
|
||||
uint32_t focusedIndex;
|
||||
if (_tabView.Items().IndexOf(_tabView.SelectedItem(), focusedIndex))
|
||||
if (_tabView.TabItems().IndexOf(_tabView.SelectedItem(), focusedIndex))
|
||||
{
|
||||
return focusedIndex;
|
||||
}
|
||||
@ -954,20 +962,6 @@ namespace winrt::TerminalApp::implementation
|
||||
_tabs[focusedTabIndex]->Scroll(termHeight * delta);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Gets a colored IconElement for the profile in question. If the profile
|
||||
// has an `icon` set in the settings, this will return an icon with that
|
||||
// image in it. Otherwise it will return a nullptr-initialized
|
||||
// IconElement.
|
||||
// Arguments:
|
||||
// - profile: the profile to get the icon from
|
||||
// Return Value:
|
||||
// - an IconElement for the profile's icon, if it has one.
|
||||
Controls::IconElement TerminalPage::_GetIconFromProfile(const Profile& profile)
|
||||
{
|
||||
return profile.HasIcon() ? GetColoredIcon(profile.GetExpandedIconPath()) : Controls::IconElement{ nullptr };
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Gets the title of the currently focused terminal control. If there
|
||||
// isn't a control selected for any reason, returns "Windows Terminal"
|
||||
@ -1029,7 +1023,7 @@ namespace winrt::TerminalApp::implementation
|
||||
// Takes into account a special case for an error condition for a comma
|
||||
// Arguments:
|
||||
// - MenuFlyoutItem that will be displayed, and a KeyChord to map an accelerator
|
||||
void TerminalPage::_SetAcceleratorForMenuItem(Controls::MenuFlyoutItem& menuItem,
|
||||
void TerminalPage::_SetAcceleratorForMenuItem(WUX::Controls::MenuFlyoutItem& menuItem,
|
||||
const winrt::Microsoft::Terminal::Settings::KeyChord& keyChord)
|
||||
{
|
||||
#ifdef DEP_MICROSOFT_UI_XAML_708_FIXED
|
||||
@ -1194,7 +1188,7 @@ namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
if (eventArgs.GetCurrentPoint(*this).Properties().IsMiddleButtonPressed())
|
||||
{
|
||||
_RemoveTabViewItem(sender);
|
||||
_RemoveTabViewItem(sender.as<MUX::Controls::TabViewItem>());
|
||||
eventArgs.Handled(true);
|
||||
}
|
||||
}
|
||||
@ -1205,7 +1199,7 @@ namespace winrt::TerminalApp::implementation
|
||||
// Arguments:
|
||||
// - sender: the control that originated this event
|
||||
// - eventArgs: the event's constituent arguments
|
||||
void TerminalPage::_OnTabSelectionChanged(const IInspectable& sender, const Controls::SelectionChangedEventArgs& eventArgs)
|
||||
void TerminalPage::_OnTabSelectionChanged(const IInspectable& sender, const WUX::Controls::SelectionChangedEventArgs& eventArgs)
|
||||
{
|
||||
auto tabView = sender.as<MUX::Controls::TabView>();
|
||||
auto selectedIndex = tabView.SelectedIndex();
|
||||
@ -1257,13 +1251,10 @@ namespace winrt::TerminalApp::implementation
|
||||
// Arguments:
|
||||
// - sender: the control that originated this event
|
||||
// - eventArgs: the event's constituent arguments
|
||||
void TerminalPage::_OnTabClosing(const IInspectable& sender, const MUX::Controls::TabViewTabClosingEventArgs& eventArgs)
|
||||
void TerminalPage::_OnTabCloseRequested(const IInspectable& sender, const MUX::Controls::TabViewTabCloseRequestedEventArgs& eventArgs)
|
||||
{
|
||||
const auto tabViewItem = eventArgs.Item();
|
||||
const auto tabViewItem = eventArgs.Tab();
|
||||
_RemoveTabViewItem(tabViewItem);
|
||||
|
||||
// If we don't cancel the event, the TabView will remove the item itself.
|
||||
eventArgs.Cancel(true);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
@ -1274,8 +1265,8 @@ namespace winrt::TerminalApp::implementation
|
||||
// Arguments:
|
||||
// - sender: unused
|
||||
// - ContentDialogButtonClickEventArgs: unused
|
||||
void TerminalPage::_CloseWarningPrimaryButtonOnClick(Windows::UI::Xaml::Controls::ContentDialog /* sender */,
|
||||
Windows::UI::Xaml::Controls::ContentDialogButtonClickEventArgs /* eventArgs*/)
|
||||
void TerminalPage::_CloseWarningPrimaryButtonOnClick(WUX::Controls::ContentDialog /* sender */,
|
||||
WUX::Controls::ContentDialogButtonClickEventArgs /* eventArgs*/)
|
||||
{
|
||||
_CloseAllTabs();
|
||||
}
|
||||
@ -1340,5 +1331,5 @@ namespace winrt::TerminalApp::implementation
|
||||
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, TitleChanged, _titleChangeHandlers, winrt::Windows::Foundation::IInspectable, winrt::hstring);
|
||||
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, LastTabClosed, _lastTabClosedHandlers, winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::LastTabClosedEventArgs);
|
||||
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, SetTitleBarContent, _setTitleBarContentHandlers, winrt::Windows::Foundation::IInspectable, UIElement);
|
||||
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, ShowDialog, _showDialogHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::UI::Xaml::Controls::ContentDialog);
|
||||
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, ShowDialog, _showDialogHandlers, winrt::Windows::Foundation::IInspectable, WUX::Controls::ContentDialog);
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ namespace winrt::TerminalApp::implementation
|
||||
Microsoft::UI::Xaml::Controls::TabView _tabView{ nullptr };
|
||||
TerminalApp::TabRowControl _tabRow{ nullptr };
|
||||
Windows::UI::Xaml::Controls::Grid _tabContent{ nullptr };
|
||||
Windows::UI::Xaml::Controls::SplitButton _newTabButton{ nullptr };
|
||||
Microsoft::UI::Xaml::Controls::SplitButton _newTabButton{ nullptr };
|
||||
|
||||
std::shared_ptr<::TerminalApp::CascadiaSettings> _settings{ nullptr };
|
||||
|
||||
@ -82,7 +82,7 @@ namespace winrt::TerminalApp::implementation
|
||||
void _UpdateTabIcon(std::shared_ptr<Tab> tab);
|
||||
void _UpdateTabView();
|
||||
void _DuplicateTabViewItem();
|
||||
void _RemoveTabViewItem(const IInspectable& tabViewItem);
|
||||
void _RemoveTabViewItem(const Microsoft::UI::Xaml::Controls::TabViewItem& tabViewItem);
|
||||
void _RemoveTabViewItemByIndex(uint32_t tabIndex);
|
||||
|
||||
void _RegisterTerminalEvents(Microsoft::Terminal::TerminalControl::TermControl term, std::shared_ptr<Tab> hostingTab);
|
||||
@ -106,7 +106,6 @@ namespace winrt::TerminalApp::implementation
|
||||
void _SplitPane(const Pane::SplitState splitType, const std::optional<GUID>& profileGuid);
|
||||
void _ResizePane(const Direction& direction);
|
||||
void _ScrollPage(int delta);
|
||||
static Windows::UI::Xaml::Controls::IconElement _GetIconFromProfile(const ::TerminalApp::Profile& profile);
|
||||
void _SetAcceleratorForMenuItem(Windows::UI::Xaml::Controls::MenuFlyoutItem& menuItem, const winrt::Microsoft::Terminal::Settings::KeyChord& keyChord);
|
||||
|
||||
void _CopyToClipboardHandler(const IInspectable& sender, const winrt::Microsoft::Terminal::TerminalControl::CopyToClipboardEventArgs& copiedData);
|
||||
@ -122,7 +121,7 @@ namespace winrt::TerminalApp::implementation
|
||||
void _OnTabSelectionChanged(const IInspectable& sender, const Windows::UI::Xaml::Controls::SelectionChangedEventArgs& eventArgs);
|
||||
void _OnTabItemsChanged(const IInspectable& sender, const Windows::Foundation::Collections::IVectorChangedEventArgs& eventArgs);
|
||||
void _OnContentSizeChanged(const IInspectable& /*sender*/, Windows::UI::Xaml::SizeChangedEventArgs const& e);
|
||||
void _OnTabClosing(const IInspectable& sender, const Microsoft::UI::Xaml::Controls::TabViewTabClosingEventArgs& eventArgs);
|
||||
void _OnTabCloseRequested(const IInspectable& sender, const Microsoft::UI::Xaml::Controls::TabViewTabCloseRequestedEventArgs& eventArgs);
|
||||
|
||||
void _RefreshUIForSettingsReload();
|
||||
|
||||
|
||||
@ -24,15 +24,14 @@ namespace winrt::TerminalApp::implementation
|
||||
MinMaxCloseControl().CloseClick({ this, &TitlebarControl::Close_Click });
|
||||
}
|
||||
|
||||
Windows::UI::Xaml::UIElement TitlebarControl::Content()
|
||||
IInspectable TitlebarControl::Content()
|
||||
{
|
||||
return ContentRoot().Children().Size() > 0 ? ContentRoot().Children().GetAt(0) : nullptr;
|
||||
return ContentRoot().Content();
|
||||
}
|
||||
|
||||
void TitlebarControl::Content(Windows::UI::Xaml::UIElement content)
|
||||
void TitlebarControl::Content(IInspectable content)
|
||||
{
|
||||
ContentRoot().Children().Clear();
|
||||
ContentRoot().Children().Append(content);
|
||||
ContentRoot().Content(content);
|
||||
}
|
||||
|
||||
void TitlebarControl::Root_SizeChanged(const IInspectable& sender,
|
||||
|
||||
@ -17,8 +17,8 @@ namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
TitlebarControl(uint64_t handle);
|
||||
|
||||
Windows::UI::Xaml::UIElement Content();
|
||||
void Content(Windows::UI::Xaml::UIElement content);
|
||||
IInspectable Content();
|
||||
void Content(IInspectable content);
|
||||
|
||||
void SetWindowVisualState(WindowVisualState visualState);
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ namespace TerminalApp
|
||||
TitlebarControl(UInt64 parentWindowHandle);
|
||||
void SetWindowVisualState(WindowVisualState visualState);
|
||||
|
||||
Windows.UI.Xaml.UIElement Content;
|
||||
IInspectable Content;
|
||||
Windows.UI.Xaml.Controls.Border DragBar { get; };
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ the MIT License. See LICENSE in the project root for license information. -->
|
||||
VerticalAlignment="Top"
|
||||
SizeChanged="Root_SizeChanged"
|
||||
d:DesignHeight="36"
|
||||
Background="{ThemeResource SystemChromeLowColor}"
|
||||
Background="{ThemeResource TabViewBackground}"
|
||||
d:DesignWidth="400">
|
||||
|
||||
<!-- TODO:GH#1988
|
||||
@ -29,7 +29,7 @@ the MIT License. See LICENSE in the project root for license information. -->
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid x:Name="ContentRoot" Grid.Column="0" />
|
||||
<ContentPresenter x:Name="ContentRoot" Grid.Column="0" />
|
||||
|
||||
<Border
|
||||
x:Name="DragBar"
|
||||
|
||||
@ -16,33 +16,3 @@ std::wstring GetWstringFromJson(const Json::Value& json)
|
||||
{
|
||||
return winrt::to_hstring(json.asString()).c_str();
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Creates an IconElement for the given path. The icon returned is a colored
|
||||
// icon. If we couldn't create the icon for any reason, we return an empty
|
||||
// IconElement.
|
||||
// Arguments:
|
||||
// - path: the full, expanded path to the icon.
|
||||
// Return Value:
|
||||
// - An IconElement with its IconSource set, if possible.
|
||||
winrt::Windows::UI::Xaml::Controls::IconElement GetColoredIcon(const winrt::hstring& path)
|
||||
{
|
||||
winrt::Windows::UI::Xaml::Controls::IconSourceElement elem{};
|
||||
if (!path.empty())
|
||||
{
|
||||
try
|
||||
{
|
||||
winrt::Windows::Foundation::Uri iconUri{ path };
|
||||
winrt::Windows::UI::Xaml::Controls::BitmapIconSource iconSource;
|
||||
// Make sure to set this to false, so we keep the RGB data of the
|
||||
// image. Otherwise, the icon will be white for all the
|
||||
// non-transparent pixels in the image.
|
||||
iconSource.ShowAsMonochrome(false);
|
||||
iconSource.UriSource(iconUri);
|
||||
elem.IconSource(iconSource);
|
||||
}
|
||||
CATCH_LOG();
|
||||
}
|
||||
|
||||
return elem;
|
||||
}
|
||||
|
||||
@ -29,8 +29,6 @@ inline std::string JsonKey(const std::string_view key)
|
||||
return static_cast<std::string>(key);
|
||||
}
|
||||
|
||||
winrt::Windows::UI::Xaml::Controls::IconElement GetColoredIcon(const winrt::hstring& path);
|
||||
|
||||
// This is a pair of helpers for determining if a pair of guids are equal, and
|
||||
// establishing an ordering on GUIDs (via std::less).
|
||||
namespace std
|
||||
@ -53,3 +51,69 @@ namespace std
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace winrt::Microsoft::UI::Xaml::Controls
|
||||
{
|
||||
struct IconSource;
|
||||
struct BitmapIconSource;
|
||||
}
|
||||
|
||||
namespace winrt::Windows::UI::Xaml::Controls
|
||||
{
|
||||
struct IconSource;
|
||||
struct BitmapIconSource;
|
||||
}
|
||||
|
||||
namespace Microsoft::TerminalApp::details
|
||||
{
|
||||
// This is a template that helps us figure out which BitmapIconSource to use for a given IconSource.
|
||||
// We have to do this because some of our code still wants to use WUX IconSources.
|
||||
template<typename TIconSource>
|
||||
struct BitmapIconSource
|
||||
{
|
||||
};
|
||||
|
||||
template<>
|
||||
struct BitmapIconSource<winrt::Microsoft::UI::Xaml::Controls::IconSource>
|
||||
{
|
||||
using type = winrt::Microsoft::UI::Xaml::Controls::BitmapIconSource;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct BitmapIconSource<winrt::Windows::UI::Xaml::Controls::IconSource>
|
||||
{
|
||||
using type = winrt::Windows::UI::Xaml::Controls::BitmapIconSource;
|
||||
};
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Creates an IconElement for the given path. The icon returned is a colored
|
||||
// icon. If we couldn't create the icon for any reason, we return an empty
|
||||
// IconElement.
|
||||
// Template Types:
|
||||
// - <TIconSource>: The type of IconSource (MUX, WUX) to generate.
|
||||
// Arguments:
|
||||
// - path: the full, expanded path to the icon.
|
||||
// Return Value:
|
||||
// - An IconElement with its IconSource set, if possible.
|
||||
template<typename TIconSource>
|
||||
TIconSource GetColoredIcon(const winrt::hstring& path)
|
||||
{
|
||||
if (!path.empty())
|
||||
{
|
||||
try
|
||||
{
|
||||
winrt::Windows::Foundation::Uri iconUri{ path };
|
||||
::Microsoft::TerminalApp::details::BitmapIconSource<TIconSource>::type iconSource;
|
||||
// Make sure to set this to false, so we keep the RGB data of the
|
||||
// image. Otherwise, the icon will be white for all the
|
||||
// non-transparent pixels in the image.
|
||||
iconSource.ShowAsMonochrome(false);
|
||||
iconSource.UriSource(iconUri);
|
||||
return iconSource;
|
||||
}
|
||||
CATCH_LOG();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -275,19 +275,13 @@
|
||||
<PropertyGroup>
|
||||
<Native-Platform Condition="'$(Platform)' == 'Win32'">x86</Native-Platform>
|
||||
<Native-Platform Condition="'$(Platform)' != 'Win32'">$(Platform)</Native-Platform>
|
||||
<_MUXRoot>$(OpenConsoleDir)\packages\Microsoft.UI.Xaml.2.2.190611001-prerelease\</_MUXRoot>
|
||||
<_MUXRoot>$(OpenConsoleDir)\packages\Microsoft.UI.Xaml.2.2.190917002\</_MUXRoot>
|
||||
<_MUXAppRoot>$(OpenConsoleDir)\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.0.0-preview7\</_MUXAppRoot>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<!-- Microsoft.UI.XAML -->
|
||||
<Reference Include="$(_MUXRoot)lib\uap10.0\Microsoft.UI.Xaml.winmd">
|
||||
<Implementation>Microsoft.UI.Xaml.dll</Implementation>
|
||||
<IsWinMDFile>true</IsWinMDFile>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<Private>true</Private>
|
||||
</Reference>
|
||||
<ReferenceCopyLocalPaths Include="$(_MUXRoot)runtimes\win10-$(Native-Platform)\native\Microsoft.UI.Xaml.dll" />
|
||||
<ReferenceCopyLocalPaths Include="$(_MUXRoot)runtimes\win10-$(Native-Platform)\native\Microsoft.UI.Xaml.pri" />
|
||||
|
||||
<!-- Microsoft.UI.XAML.Application -->
|
||||
<Reference Include="$(_MUXAppRoot)lib\uap10.0\Microsoft.Toolkit.Win32.UI.XamlHost.winmd">
|
||||
@ -305,7 +299,7 @@
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('$(OpenConsoleDir)\packages\Microsoft.UI.Xaml.2.2.190611001-prerelease\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(OpenConsoleDir)\packages\Microsoft.UI.Xaml.2.2.190611001-prerelease\build\native\Microsoft.UI.Xaml.targets'))" />
|
||||
<Error Condition="!Exists('$(OpenConsoleDir)\packages\Microsoft.UI.Xaml.2.2.190917002\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(OpenConsoleDir)\packages\Microsoft.UI.Xaml.2.2.190917002\build\native\Microsoft.UI.Xaml.targets'))" />
|
||||
<Error Condition="!Exists('$(OpenConsoleDir)\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.0.0-preview7\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(OpenConsoleDir)\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.0.0-preview7\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets'))" />
|
||||
</Target>
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Toolkit.Win32.UI.XamlApplication" version="6.0.0-preview7" targetFramework="native" />
|
||||
<package id="Microsoft.UI.Xaml" version="2.2.190611001-prerelease" targetFramework="native" />
|
||||
<package id="Microsoft.UI.Xaml" version="2.2.190917002" targetFramework="native" />
|
||||
<package id="Microsoft.Windows.CppWinRT" version="2.0.190730.2" targetFramework="native" />
|
||||
</packages>
|
||||
|
||||
@ -84,8 +84,16 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
|
||||
|
||||
// Initialize the terminal only once the swapchainpanel is loaded - that
|
||||
// way, we'll be able to query the real pixel size it got on layout
|
||||
_loadedRevoker = swapChainPanel.Loaded(winrt::auto_revoke, [this](auto /*s*/, auto /*e*/) {
|
||||
_InitializeTerminal();
|
||||
_layoutUpdatedRevoker = swapChainPanel.LayoutUpdated(winrt::auto_revoke, [this](auto /*s*/, auto /*e*/) {
|
||||
// This event fires every time the layout changes, but it is always the last one to fire
|
||||
// in any layout change chain. That gives us great flexibility in finding the right point
|
||||
// at which to initialize our renderer (and our terminal).
|
||||
// Any earlier than the last layout update and we may not know the terminal's starting size.
|
||||
if (_InitializeTerminal())
|
||||
{
|
||||
// Only let this succeed once.
|
||||
this->_layoutUpdatedRevoker.revoke();
|
||||
}
|
||||
});
|
||||
|
||||
container.Children().Append(swapChainPanel);
|
||||
@ -382,16 +390,21 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
|
||||
});
|
||||
}
|
||||
|
||||
void TermControl::_InitializeTerminal()
|
||||
bool TermControl::_InitializeTerminal()
|
||||
{
|
||||
if (_initializedTerminal)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto windowWidth = _swapChainPanel.ActualWidth(); // Width() and Height() are NaN?
|
||||
const auto windowHeight = _swapChainPanel.ActualHeight();
|
||||
|
||||
if (windowWidth == 0 || windowHeight == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_terminal = std::make_unique<::Microsoft::Terminal::Core::Terminal>();
|
||||
|
||||
// First create the render thread.
|
||||
@ -565,6 +578,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
|
||||
|
||||
_connection.Start();
|
||||
_initializedTerminal = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void TermControl::_CharacterHandler(winrt::Windows::Foundation::IInspectable const& /*sender*/,
|
||||
|
||||
@ -142,7 +142,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
|
||||
// lest we get callbacks afterwards.
|
||||
winrt::Windows::UI::Xaml::Controls::Control::SizeChanged_revoker _sizeChangedRevoker;
|
||||
winrt::Windows::UI::Xaml::Controls::SwapChainPanel::CompositionScaleChanged_revoker _compositionScaleChangedRevoker;
|
||||
winrt::Windows::UI::Xaml::Controls::SwapChainPanel::Loaded_revoker _loadedRevoker;
|
||||
winrt::Windows::UI::Xaml::Controls::SwapChainPanel::LayoutUpdated_revoker _layoutUpdatedRevoker;
|
||||
winrt::Windows::UI::Xaml::UIElement::LostFocus_revoker _lostFocusRevoker;
|
||||
winrt::Windows::UI::Xaml::UIElement::GotFocus_revoker _gotFocusRevoker;
|
||||
|
||||
@ -150,7 +150,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
|
||||
void _ApplyUISettings();
|
||||
void _InitializeBackgroundBrush();
|
||||
void _BackgroundColorChanged(const uint32_t color);
|
||||
void _InitializeTerminal();
|
||||
bool _InitializeTerminal();
|
||||
void _UpdateFont();
|
||||
void _KeyDownHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs const& e);
|
||||
void _CharacterHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::Input::CharacterReceivedRoutedEventArgs const& e);
|
||||
|
||||
@ -72,7 +72,7 @@ void NonClientIslandWindow::Initialize()
|
||||
_titlebar = winrt::TerminalApp::TitlebarControl{ reinterpret_cast<uint64_t>(GetHandle()) };
|
||||
_dragBar = _titlebar.DragBar();
|
||||
|
||||
_rootGrid.SizeChanged({ this, &NonClientIslandWindow::OnDragBarSizeChanged });
|
||||
_dragBar.SizeChanged({ this, &NonClientIslandWindow::OnDragBarSizeChanged });
|
||||
|
||||
_rootGrid.Children().Append(_titlebar);
|
||||
|
||||
@ -110,14 +110,6 @@ void NonClientIslandWindow::SetContent(winrt::Windows::UI::Xaml::UIElement conte
|
||||
void NonClientIslandWindow::SetTitlebarContent(winrt::Windows::UI::Xaml::UIElement content)
|
||||
{
|
||||
_titlebar.Content(content);
|
||||
|
||||
// When the size of the titlebar content changes, we want to make sure to
|
||||
// update the size of the drag region as well.
|
||||
const auto fwe = content.try_as<winrt::Windows::UI::Xaml::FrameworkElement>();
|
||||
if (fwe)
|
||||
{
|
||||
fwe.SizeChanged({ this, &NonClientIslandWindow::OnDragBarSizeChanged });
|
||||
}
|
||||
}
|
||||
|
||||
RECT NonClientIslandWindow::GetDragAreaRect() const noexcept
|
||||
|
||||
@ -103,12 +103,12 @@
|
||||
<NoOutputRedirection>true</NoOutputRedirection>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\..\..\packages\Microsoft.UI.Xaml.2.2.190611001-prerelease\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\..\packages\Microsoft.UI.Xaml.2.2.190611001-prerelease\build\native\Microsoft.UI.Xaml.targets')" />
|
||||
<Import Project="..\..\..\packages\Microsoft.UI.Xaml.2.2.190917002\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\..\packages\Microsoft.UI.Xaml.2.2.190917002\build\native\Microsoft.UI.Xaml.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\..\packages\Microsoft.UI.Xaml.2.2.190611001-prerelease\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.UI.Xaml.2.2.190611001-prerelease\build\native\Microsoft.UI.Xaml.targets'))" />
|
||||
<Error Condition="!Exists('..\..\..\packages\Microsoft.UI.Xaml.2.2.190917002\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.UI.Xaml.2.2.190917002\build\native\Microsoft.UI.Xaml.targets'))" />
|
||||
<Error Condition="!Exists('..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.0.0-preview7\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.0.0-preview7\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.props'))" />
|
||||
<Error Condition="!Exists('..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.0.0-preview7\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.0.0-preview7\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets'))" />
|
||||
<Error Condition="!Exists('..\..\..\packages\Microsoft.VCRTForwarders.140.1.0.1-rc\build\native\Microsoft.VCRTForwarders.140.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.VCRTForwarders.140.1.0.1-rc\build\native\Microsoft.VCRTForwarders.140.targets'))" />
|
||||
|
||||
@ -2,6 +2,6 @@
|
||||
<packages>
|
||||
<package id="Microsoft.Windows.CppWinRT" version="2.0.190730.2" targetFramework="native" />
|
||||
<package id="Microsoft.Toolkit.Win32.UI.XamlApplication" version="6.0.0-preview7" targetFramework="native" />
|
||||
<package id="Microsoft.UI.Xaml" version="2.2.190611001-prerelease" targetFramework="native" />
|
||||
<package id="Microsoft.UI.Xaml" version="2.2.190917002" targetFramework="native" />
|
||||
<package id="Microsoft.VCRTForwarders.140" version="1.0.1-rc" targetFramework="native" />
|
||||
</packages>
|
||||
|
||||
@ -82,7 +82,7 @@
|
||||
<!-- From Microsoft.UI.Xaml.targets -->
|
||||
<Native-Platform Condition="'$(Platform)' == 'Win32'">x86</Native-Platform>
|
||||
<Native-Platform Condition="'$(Platform)' != 'Win32'">$(Platform)</Native-Platform>
|
||||
<_MUXBinRoot>"$(OpenConsoleDir)packages\Microsoft.UI.Xaml.2.2.190611001-prerelease\runtimes\win10-$(Native-Platform)\native\"</_MUXBinRoot>
|
||||
<_MUXBinRoot>"$(OpenConsoleDir)packages\Microsoft.UI.Xaml.2.2.190917002\runtimes\win10-$(Native-Platform)\native\"</_MUXBinRoot>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemDefinitionGroup>
|
||||
@ -110,13 +110,6 @@
|
||||
echo OutDir=$(OutDir)
|
||||
(xcopy /Y "$(OpenConsoleDir)src\cascadia\ut_app\TerminalApp.Unit.Tests.manifest" "$(OutDir)\TerminalApp.Unit.Tests.manifest*" )
|
||||
(xcopy /Y "$(OpenConsoleDir)src\cascadia\ut_app\TerminalApp.Unit.Tests.AppxManifest.xml" "$(OutDir)\TerminalApp.Unit.Tests.AppxManifest.xml*" )
|
||||
|
||||
(xcopy /Y $(_CppWinrtBinRoot)TerminalConnection\TerminalConnection.dll "$(OutDir)\TerminalConnection.dll*" )
|
||||
(xcopy /Y $(_CppWinrtBinRoot)TerminalSettings\TerminalSettings.dll "$(OutDir)\TerminalSettings.dll*" )
|
||||
(xcopy /Y $(_CppWinrtBinRoot)TerminalControl\TerminalControl.dll "$(OutDir)\TerminalControl.dll*" )
|
||||
|
||||
(xcopy /Y $(_MUXBinRoot)Microsoft.UI.Xaml.dll "$(OutDir)\Microsoft.UI.Xaml.dll*" )
|
||||
(xcopy /Y $(_MUXBinRoot)Microsoft.UI.Xaml.pri "$(OutDir)\Microsoft.UI.Xaml.pri*" )
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user