* 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.
93 lines
3.4 KiB
C++
93 lines
3.4 KiB
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
#pragma once
|
|
|
|
#include "Tab.h"
|
|
#include "CascadiaSettings.h"
|
|
#include "TerminalPage.h"
|
|
#include "App.g.h"
|
|
#include "App.base.h"
|
|
#include "../../cascadia/inc/cppwinrt_utils.h"
|
|
|
|
#include <winrt/Microsoft.Terminal.TerminalControl.h>
|
|
#include <winrt/Microsoft.Terminal.TerminalConnection.h>
|
|
|
|
#include <winrt/Microsoft.UI.Xaml.Controls.h>
|
|
#include <winrt/Microsoft.UI.Xaml.Controls.Primitives.h>
|
|
#include <winrt/Microsoft.UI.Xaml.XamlTypeInfo.h>
|
|
|
|
#include <winrt/Windows.ApplicationModel.DataTransfer.h>
|
|
|
|
namespace winrt::TerminalApp::implementation
|
|
{
|
|
struct App : AppT2<App>
|
|
{
|
|
public:
|
|
App();
|
|
~App() = default;
|
|
|
|
void Create();
|
|
void LoadSettings();
|
|
|
|
Windows::Foundation::Point GetLaunchDimensions(uint32_t dpi);
|
|
bool GetShowTabsInTitlebar();
|
|
|
|
Windows::UI::Xaml::UIElement GetRoot() noexcept;
|
|
|
|
hstring Title();
|
|
void TitlebarClicked();
|
|
|
|
void WindowCloseButtonClicked();
|
|
|
|
// -------------------------------- WinRT Events ---------------------------------
|
|
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(TitleChanged, _titleChangeHandlers, winrt::Windows::Foundation::IInspectable, winrt::hstring);
|
|
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(LastTabClosed, _lastTabClosedHandlers, winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::LastTabClosedEventArgs);
|
|
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(SetTitleBarContent, _setTitleBarContentHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::UI::Xaml::UIElement);
|
|
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(RequestedThemeChanged, _requestedThemeChangedHandlers, TerminalApp::App, winrt::Windows::UI::Xaml::ElementTheme);
|
|
|
|
private:
|
|
// If you add controls here, but forget to null them either here or in
|
|
// the ctor, you're going to have a bad time. It'll mysteriously fail to
|
|
// activate the app.
|
|
// ALSO: If you add any UIElements as roots here, make sure they're
|
|
// updated in _ApplyTheme. The root currently is _root.
|
|
winrt::com_ptr<TerminalPage> _root{ nullptr };
|
|
|
|
std::shared_ptr<::TerminalApp::CascadiaSettings> _settings{ nullptr };
|
|
|
|
std::shared_ptr<ScopedResourceLoader> _resourceLoader{ nullptr };
|
|
|
|
HRESULT _settingsLoadedResult;
|
|
winrt::hstring _settingsLoadExceptionText{};
|
|
|
|
bool _loadedInitialSettings;
|
|
|
|
wil::unique_folder_change_reader_nothrow _reader;
|
|
|
|
std::shared_mutex _dialogLock;
|
|
|
|
std::atomic<bool> _settingsReloadQueued{ false };
|
|
|
|
fire_and_forget _ShowDialog(const winrt::Windows::Foundation::IInspectable& sender, winrt::Windows::UI::Xaml::Controls::ContentDialog dialog);
|
|
void _ShowLoadErrorsDialog(const winrt::hstring& titleKey, const winrt::hstring& contentKey, HRESULT settingsLoadedResult);
|
|
void _ShowLoadWarningsDialog();
|
|
|
|
void _OnLoaded(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);
|
|
|
|
[[nodiscard]] HRESULT _TryLoadSettings() noexcept;
|
|
void _RegisterSettingsChange();
|
|
fire_and_forget _DispatchReloadSettings();
|
|
void _ReloadSettings();
|
|
|
|
void _ApplyTheme(const Windows::UI::Xaml::ElementTheme& newTheme);
|
|
};
|
|
}
|
|
|
|
namespace winrt::TerminalApp::factory_implementation
|
|
{
|
|
struct App : AppT<App, implementation::App>
|
|
{
|
|
};
|
|
}
|