c18c240627
BODGY! This solution was suggested in https://github.com/microsoft/microsoft-ui-xaml/issues/4554#issuecomment-887815332. When the window moves, or when a ScrollViewer scrolls, dismiss any popups that are visible. This happens automagically when an app is a real XAML app, but it doesn't work for XAML Islands. * upstream at https://github.com/microsoft/microsoft-ui-xaml/issues/4554 * [x] Closes #9320 * [x] I work here * [ ] Tests added/passed * [ ] Requires documentation to be updated Unfortunately, we've got a bunch of scroll viewers in our SUI. So I did something bodgyx2 to make our life a little easier. `DismissAllPopups` can be used to dismiss all popups for a particular UI element. However, we've got a bunch of pages with scroll viewers that may or may not have popups in them. Rather than define the same exact body for all their `ViewChanging` events, the `HasScrollViewer` struct will just do it for you! Inside the `HasScrollViewer` stuct, we can't get at the `XamlRoot()` that our subclass implements. I mean, _we_ can, but when XAML does it's codegen, _XAML_ won't be able to figure it out. Fortunately for us, we don't need to! The sender is a UIElement, so we can just get _their_ `XamlRoot()`. So, you can fix this for any SUI page with just a simple ```diff - <ScrollViewer> + <ScrollViewer ViewChanging="ViewChanging"> ``` ```diff - struct AddProfile : AddProfileT<AddProfile> + struct AddProfile : public HasScrollViewer<AddProfile>, AddProfileT<AddProfile> ``` * the window doesn't close when you move it * the popups _do_ close when you move the window * the popups close when you scroll any SUI page
53 lines
2.2 KiB
C++
53 lines
2.2 KiB
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
#pragma once
|
|
|
|
#include "GlobalAppearance.g.h"
|
|
#include "GlobalAppearancePageNavigationState.g.h"
|
|
#include "Utils.h"
|
|
|
|
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|
{
|
|
struct GlobalAppearancePageNavigationState : GlobalAppearancePageNavigationStateT<GlobalAppearancePageNavigationState>
|
|
{
|
|
public:
|
|
GlobalAppearancePageNavigationState(const Model::GlobalAppSettings& settings) :
|
|
_Globals{ settings } {}
|
|
|
|
WINRT_PROPERTY(Model::GlobalAppSettings, Globals, nullptr)
|
|
};
|
|
|
|
struct GlobalAppearance : public HasScrollViewer<GlobalAppearance>, GlobalAppearanceT<GlobalAppearance>
|
|
{
|
|
public:
|
|
GlobalAppearance();
|
|
|
|
void OnNavigatedTo(const winrt::Windows::UI::Xaml::Navigation::NavigationEventArgs& e);
|
|
|
|
WINRT_PROPERTY(Editor::GlobalAppearancePageNavigationState, State, nullptr);
|
|
GETSET_BINDABLE_ENUM_SETTING(Theme, winrt::Windows::UI::Xaml::ElementTheme, State().Globals, Theme);
|
|
GETSET_BINDABLE_ENUM_SETTING(TabWidthMode, winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode, State().Globals, TabWidthMode);
|
|
|
|
public:
|
|
// LanguageDisplayConverter maps the given BCP 47 tag to a localized string.
|
|
// For instance "en-US" produces "English (United States)", while "de-DE" produces
|
|
// "Deutsch (Deutschland)". This works independently of the user's locale.
|
|
static winrt::hstring LanguageDisplayConverter(const winrt::hstring& tag);
|
|
|
|
bool LanguageSelectorAvailable();
|
|
winrt::Windows::Foundation::Collections::IObservableVector<winrt::hstring> LanguageList();
|
|
winrt::Windows::Foundation::IInspectable CurrentLanguage();
|
|
void CurrentLanguage(const winrt::Windows::Foundation::IInspectable& tag);
|
|
|
|
private:
|
|
winrt::Windows::Foundation::Collections::IObservableVector<winrt::hstring> _languageList;
|
|
winrt::Windows::Foundation::IInspectable _currentLanguage;
|
|
};
|
|
}
|
|
|
|
namespace winrt::Microsoft::Terminal::Settings::Editor::factory_implementation
|
|
{
|
|
BASIC_FACTORY(GlobalAppearance);
|
|
}
|