Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Represent inheritance in Settings UI #8919

Merged
18 commits merged into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/cascadia/TerminalControl/TermControl.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<UserControl
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under
the MIT License. See LICENSE in the project root for license information. -->
carlos-zamora marked this conversation as resolved.
Show resolved Hide resolved
<UserControl
x:Class="Microsoft.Terminal.TerminalControl.TermControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Expand Down
12 changes: 10 additions & 2 deletions src/cascadia/TerminalSettingsEditor/CommonResources.xaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
<ResourceDictionary
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under
the MIT License. See LICENSE in the project root for license information. -->
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls">

<!--Merge SettingContainerStyle here to give every page access to the SettingContainer-->
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="SettingContainerStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>

<x:Double x:Key="StandardIconSize">14.0</x:Double>
<Thickness x:Key="StandardIndentMargin">13,0,0,0</Thickness>
<Thickness x:Key="StandardControlMargin">0,24,0,0</Thickness>
<Thickness x:Key="StandardHeaderSpacing">0,0,0,4</Thickness>
<x:Double x:Key="StandardBoxMinWidth">250</x:Double>

<!-- This is for easier transition to the SettingsContainer control.
Expand Down Expand Up @@ -46,7 +54,7 @@

<!--Used to create a header for a control-->
<Style x:Key="CustomSettingHeaderStyle" TargetType="TextBlock">
<Setter Property="Margin" Value="0,0,0,4"/>
<Setter Property="Margin" Value="{StaticResource StandardHeaderSpacing}"/>
</Style>

<!--Used for disclaimers-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@
<ClInclude Include="Rendering.h">
<DependentUpon>Rendering.xaml</DependentUpon>
</ClInclude>
<ClInclude Include="SettingContainer.h">
<DependentUpon>SettingContainer.idl</DependentUpon>
</ClInclude>
<ClInclude Include="Utils.h" />
</ItemGroup>
<!-- ========================= XAML files ======================== -->
Expand Down Expand Up @@ -117,6 +120,9 @@
<Page Include="Rendering.xaml">
<SubType>Designer</SubType>
</Page>
<Page Include="SettingContainerStyle.xaml">
<Type>DefaultStyle</Type>
</Page>
</ItemGroup>
<!-- ========================= Cpp Files ======================== -->
<ItemGroup>
Expand Down Expand Up @@ -174,6 +180,9 @@
<ClCompile Include="Rendering.cpp">
<DependentUpon>Rendering.xaml</DependentUpon>
</ClCompile>
<ClCompile Include="SettingContainer.cpp">
<DependentUpon>SettingContainer.idl</DependentUpon>
</ClCompile>
<ClCompile Include="Utils.cpp" />
</ItemGroup>
<!-- ========================= idl Files ======================== -->
Expand Down Expand Up @@ -207,6 +216,9 @@
<DependentUpon>Profiles.xaml</DependentUpon>
<SubType>Code</SubType>
</Midl>
<Midl Include="SettingContainer.idl">
<SubType>Code</SubType>
</Midl>
</ItemGroup>
<!-- ========================= Misc Files ======================== -->
<ItemGroup>
Expand Down
74 changes: 62 additions & 12 deletions src/cascadia/TerminalSettingsEditor/Profiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using namespace winrt::Windows::UI::Text;
using namespace winrt::Windows::UI::Xaml;
using namespace winrt::Windows::UI::Xaml::Controls;
using namespace winrt::Windows::UI::Xaml::Data;
using namespace winrt::Windows::UI::Xaml::Navigation;
using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::Foundation::Collections;
Expand Down Expand Up @@ -39,7 +40,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
// box, prevent it from ever being changed again.
//
// We do the same for the starting directory path
PropertyChanged([this](auto&&, const Data::PropertyChangedEventArgs& args) {
PropertyChanged([this](auto&&, const PropertyChangedEventArgs& args) {
if (args.PropertyName() == L"BackgroundImagePath")
{
_NotifyChanges(L"UseDesktopBGImage", L"BackgroundImageSettingsVisible");
Expand All @@ -50,8 +51,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
}
else if (args.PropertyName() == L"StartingDirectory")
{
_NotifyChanges(L"UseParentProcessDirectory");
_NotifyChanges(L"UseCustomStartingDirectory");
_NotifyChanges(L"UseParentProcessDirectory", L"UseCustomStartingDirectory");
}
});

Expand Down Expand Up @@ -114,7 +114,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
}
BackgroundImagePath(L"desktopWallpaper");
}
else
else if (HasBackgroundImagePath())
{
// Restore the path we had previously cached. This might be the
// empty string.
Expand Down Expand Up @@ -151,7 +151,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
}
StartingDirectory(L"");
}
else
else if (HasStartingDirectory())
{
// Restore the path we had previously cached as long as it wasn't empty
// If it was empty, set the starting directory to %USERPROFILE%
Expand Down Expand Up @@ -206,9 +206,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
_BIAlignmentButtons.at(6) = BIAlign_BottomLeft();
_BIAlignmentButtons.at(7) = BIAlign_Bottom();
_BIAlignmentButtons.at(8) = BIAlign_BottomRight();

Profile_Padding().Text(RS_(L"Profile_Padding/Header"));
ToolTipService::SetToolTip(Padding_Presenter(), box_value(RS_(L"Profile_Padding/[using:Windows.UI.Xaml.Controls]ToolTipService/ToolTip")));
}

void Profiles::OnNavigatedTo(const NavigationEventArgs& e)
Expand Down Expand Up @@ -248,6 +245,59 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
StartingDirectoryUseParentCheckbox().IsChecked(true);
}

// Subscribe to some changes in the view model
// These changes should force us to update our own set of "Current<Setting>" members,
// and propagate those changes to the UI
_State.Profile().PropertyChanged([&](auto&&, const PropertyChangedEventArgs& args) {
carlos-zamora marked this conversation as resolved.
Show resolved Hide resolved
if (args.PropertyName() == L"CursorShape")
carlos-zamora marked this conversation as resolved.
Show resolved Hide resolved
{
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentCursorShape" });
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"IsVintageCursor" });
}
else if (args.PropertyName() == L"BackgroundImageStretchMode")
{
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentBackgroundImageStretchMode" });
}
else if (args.PropertyName() == L"AntialiasingMode")
{
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentAntiAliasingMode" });
}
else if (args.PropertyName() == L"CloseOnExit")
{
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentCloseOnExitMode" });
}
else if (args.PropertyName() == L"BellStyle")
{
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentBellStyle" });
}
else if (args.PropertyName() == L"ScrollState")
{
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentScrollState" });
}
else if (args.PropertyName() == L"FontWeight")
{
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentFontWeight" });
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"IsCustomFontWeight" });
}
else if (args.PropertyName() == L"ColorSchemeName")
{
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentColorScheme" });
}
else if (args.PropertyName() == L"BackgroundImageAlignment")
{
// reset all of the buttons to unchecked.
// set the one for the value we actually have.
const auto alignment{ static_cast<int32_t>(_State.Profile().BackgroundImageAlignment()) };
for (const auto& biButton : _BIAlignmentButtons)
{
if (const auto& biButtonAlignment{ biButton.Tag().try_as<int32_t>() })
{
biButton.IsChecked(biButtonAlignment == alignment);
}
}
}
});

// Navigate to the pivot in the provided navigation state
ProfilesPivot().SelectedIndex(static_cast<int>(_State.LastActivePivot()));
}
Expand Down Expand Up @@ -374,7 +424,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
// So the TwoWay binding doesn't update on the State --> Slider direction
FontWeightSlider().Value(weight);
}
_PropertyChangedHandlers(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"IsCustomFontWeight" });
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"IsCustomFontWeight" });
}
}

Expand All @@ -388,7 +438,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation

void Profiles::BIAlignment_Click(IInspectable const& sender, RoutedEventArgs const& /*e*/)
{
if (const auto& button{ sender.try_as<Windows::UI::Xaml::Controls::Primitives::ToggleButton>() })
if (const auto& button{ sender.try_as<Primitives::ToggleButton>() })
{
if (const auto& tag{ button.Tag().try_as<int32_t>() })
{
Expand All @@ -406,7 +456,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation

void Profiles::CursorShape_Changed(IInspectable const& /*sender*/, RoutedEventArgs const& /*e*/)
{
_PropertyChangedHandlers(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"IsVintageCursor" });
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"IsVintageCursor" });
}
carlos-zamora marked this conversation as resolved.
Show resolved Hide resolved

bool Profiles::IsVintageCursor() const
Expand All @@ -415,7 +465,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
}

void Profiles::Pivot_SelectionChanged(Windows::Foundation::IInspectable const& /*sender*/,
Windows::UI::Xaml::RoutedEventArgs const& /*e*/)
RoutedEventArgs const& /*e*/)
{
_State.LastActivePivot(static_cast<Editor::ProfilesPivots>(ProfilesPivot().SelectedIndex()));
}
Expand Down
2 changes: 0 additions & 2 deletions src/cascadia/TerminalSettingsEditor/Profiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
fire_and_forget Icon_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e);
void BIAlignment_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e);
void DeleteConfirmation_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e);
void UseParentProcessDirectory_Check(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e);
void UseParentProcessDirectory_Uncheck(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e);
void Pivot_SelectionChanged(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e);

// CursorShape visibility logic
Expand Down
Loading