Add UI for adding, renaming, and deleting a color scheme (#8403)
Introduces the following UI controls to the ColorSchemes page: - "Add new" button - next to dropdown selector - adds a new color scheme named ("Color Scheme #" where # is the number of color schemes you have) - "Rename" Button - next to the selector - replaces the ComboBox with a TextBox and the accept/cancel buttons appear - "Delete" button - bottom of the page - opens flyout, when confirmed, deletes the current color scheme and selects another one This also adds a Delete button to the Profiles page. The Hide checkbox was moved above the Delete button. ## References #1564 - Settings UI #6800 - Settings UI Completion Epic ## Detailed Description of the Pull Request / Additional comments **Color Schemes:** - Deleting a color scheme selects another one from the list available - Rename replaces the combobox with a textbox to allow editing - The Add New button creates a new color scheme named "Color Scheme X" where X is the number of schemes defined - In-box color schemes cannot be deleted **Profile:** - Deleting a profile selects another one from the list available - the rename button does not exist (yet), because it needs a modification to the NavigationView's Header Template - The delete button is disabled for in-box profiles (CMD and Windows Powershell) and dynamic profiles ## Validation Steps Performed **Color Schemes - Add New** ✅ Creates a new color scheme named "Color Scheme X" (X being the number of color schemes) ✅ The new color scheme can be renamed/deleted/modified **Color Schemes - Rename** ✅ You cannot rename an in-box color scheme ✅ The rename button has a tooltip ✅ Clicking the rename button replaces the combobox with a textbox ✅ Accept --> changes name ✅ Cancel --> does not change the name ✅ accepting/cancelling the rename operation updates the combo box appropriately **Color Schemes - Delete** ✅ Clicking delete produces a flyout to confirm deletion ✅ Deleting a color scheme removes it from the list and select the one under it ✅ Deleting the last color scheme selects the last available color scheme after it's deleted ✅ In-box color schemes have the delete button disabled, and a disclaimer appears next to it **Profile- Delete** ✅ Base layer presents a disclaimer at the top, and hides the delete button ✅ Dynamic and in-box profiles disable the delete button and show the appropriate disclaimer next to the disabled button ✅ Clicking delete produces a flyout to confirm deletion ✅ Regular profiles have a delete button that is styled appropriately ✅ Clicking the delete profile button opens a content dialog. Confirmation deletes the profile and navigates to the profile indexed under it (deleting the last one redirects to the last one) ## Demo Refer to this post [here](https://github.com/microsoft/terminal/pull/8403#issuecomment-747545651. Confirmation flyout demo: https://github.com/microsoft/terminal/pull/8403#issuecomment-747657842
This commit is contained in:
parent
c5366cea75
commit
33470ad08e
|
@ -11,6 +11,7 @@
|
|||
|
||||
using namespace winrt;
|
||||
using namespace winrt::Windows::UI;
|
||||
using namespace winrt::Windows::UI::Xaml;
|
||||
using namespace winrt::Windows::UI::Xaml::Navigation;
|
||||
using namespace winrt::Windows::UI::Xaml::Controls;
|
||||
using namespace winrt::Windows::UI::Xaml::Media;
|
||||
|
@ -38,8 +39,20 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
RS_(L"ColorScheme_BrightWhite/Header")
|
||||
};
|
||||
|
||||
static const std::array<std::wstring, 9> InBoxSchemes = {
|
||||
L"Campbell",
|
||||
L"Campbell Powershell",
|
||||
L"Vintage",
|
||||
L"One Half Dark",
|
||||
L"One Half Light",
|
||||
L"Solarized Dark",
|
||||
L"Solarized Light",
|
||||
L"Tango Dark",
|
||||
L"Tango Light"
|
||||
};
|
||||
|
||||
ColorSchemes::ColorSchemes() :
|
||||
_ColorSchemeList{ single_threaded_observable_vector<hstring>() },
|
||||
_ColorSchemeList{ single_threaded_observable_vector<Model::ColorScheme>() },
|
||||
_CurrentColorTable{ single_threaded_observable_vector<Editor::ColorTableEntry>() }
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -73,10 +86,23 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
SelectionChangedEventArgs const& args)
|
||||
{
|
||||
// Update the color scheme this page is modifying
|
||||
auto str = winrt::unbox_value<hstring>(args.AddedItems().GetAt(0));
|
||||
auto colorScheme = _State.Globals().ColorSchemes().Lookup(str);
|
||||
const auto colorScheme{ args.AddedItems().GetAt(0).try_as<Model::ColorScheme>() };
|
||||
CurrentColorScheme(colorScheme);
|
||||
_UpdateColorTable(colorScheme);
|
||||
|
||||
// Set the text disclaimer for the text box
|
||||
hstring disclaimer{};
|
||||
const std::wstring schemeName{ colorScheme.Name() };
|
||||
if (std::find(std::begin(InBoxSchemes), std::end(InBoxSchemes), schemeName) != std::end(InBoxSchemes))
|
||||
{
|
||||
// load disclaimer for in-box profiles
|
||||
disclaimer = RS_(L"ColorScheme_DeleteButtonDisclaimerInBox");
|
||||
}
|
||||
DeleteButtonDisclaimer().Text(disclaimer);
|
||||
|
||||
// Update the state of the page
|
||||
_PropertyChangedHandlers(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"CanDeleteCurrentScheme" });
|
||||
IsRenaming(false);
|
||||
}
|
||||
|
||||
// Function Description:
|
||||
|
@ -92,7 +118,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
const auto& colorSchemeMap{ _State.Globals().ColorSchemes() };
|
||||
for (const auto& pair : colorSchemeMap)
|
||||
{
|
||||
_ColorSchemeList.Append(pair.Key());
|
||||
_ColorSchemeList.Append(pair.Value());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,6 +146,101 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
}
|
||||
}
|
||||
|
||||
bool ColorSchemes::CanDeleteCurrentScheme() const
|
||||
{
|
||||
if (const auto scheme{ CurrentColorScheme() })
|
||||
{
|
||||
// Only allow this color scheme to be deleted if it's not provided in-box
|
||||
const std::wstring myName{ scheme.Name() };
|
||||
return std::find(std::begin(InBoxSchemes), std::end(InBoxSchemes), myName) == std::end(InBoxSchemes);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ColorSchemes::DeleteConfirmation_Click(IInspectable const& /*sender*/, RoutedEventArgs const& /*e*/)
|
||||
{
|
||||
const auto schemeName{ CurrentColorScheme().Name() };
|
||||
_State.Globals().RemoveColorScheme(schemeName);
|
||||
|
||||
const auto removedSchemeIndex{ ColorSchemeComboBox().SelectedIndex() };
|
||||
if (static_cast<uint32_t>(removedSchemeIndex) < _ColorSchemeList.Size() - 1)
|
||||
{
|
||||
// select same index
|
||||
ColorSchemeComboBox().SelectedIndex(removedSchemeIndex + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// select last color scheme (avoid out of bounds error)
|
||||
ColorSchemeComboBox().SelectedIndex(removedSchemeIndex - 1);
|
||||
}
|
||||
_ColorSchemeList.RemoveAt(removedSchemeIndex);
|
||||
DeleteButton().Flyout().Hide();
|
||||
}
|
||||
|
||||
void ColorSchemes::AddNew_Click(IInspectable const& /*sender*/, RoutedEventArgs const& /*e*/)
|
||||
{
|
||||
// Give the new scheme a distinct name
|
||||
const hstring schemeName{ fmt::format(L"Color Scheme {}", _State.Globals().ColorSchemes().Size() + 1) };
|
||||
Model::ColorScheme scheme{ schemeName };
|
||||
|
||||
// Add the new color scheme
|
||||
_State.Globals().AddColorScheme(scheme);
|
||||
|
||||
// Update current page
|
||||
_ColorSchemeList.Append(scheme);
|
||||
ColorSchemeComboBox().SelectedItem(scheme);
|
||||
}
|
||||
|
||||
// Function Description:
|
||||
// - Pre-populates/focuses the name TextBox, updates the UI
|
||||
// Arguments:
|
||||
// - <unused>
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void ColorSchemes::Rename_Click(IInspectable const& /*sender*/, RoutedEventArgs const& /*e*/)
|
||||
{
|
||||
NameBox().Text(CurrentColorScheme().Name());
|
||||
IsRenaming(true);
|
||||
NameBox().Focus(FocusState::Programmatic);
|
||||
NameBox().SelectAll();
|
||||
}
|
||||
|
||||
void ColorSchemes::RenameAccept_Click(IInspectable const& /*sender*/, RoutedEventArgs const& /*e*/)
|
||||
{
|
||||
_RenameCurrentScheme(NameBox().Text());
|
||||
}
|
||||
|
||||
void ColorSchemes::RenameCancel_Click(IInspectable const& /*sender*/, RoutedEventArgs const& /*e*/)
|
||||
{
|
||||
IsRenaming(false);
|
||||
}
|
||||
|
||||
void ColorSchemes::NameBox_PreviewKeyDown(IInspectable const& /*sender*/, winrt::Windows::UI::Xaml::Input::KeyRoutedEventArgs const& e)
|
||||
{
|
||||
if (e.OriginalKey() == winrt::Windows::System::VirtualKey::Enter)
|
||||
{
|
||||
_RenameCurrentScheme(NameBox().Text());
|
||||
e.Handled(true);
|
||||
}
|
||||
else if (e.OriginalKey() == winrt::Windows::System::VirtualKey::Escape)
|
||||
{
|
||||
IsRenaming(false);
|
||||
e.Handled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void ColorSchemes::_RenameCurrentScheme(hstring newName)
|
||||
{
|
||||
CurrentColorScheme().Name(newName);
|
||||
IsRenaming(false);
|
||||
|
||||
// The color scheme is renamed appropriately, but the ComboBox still shows the old name (until you open it)
|
||||
// We need to manually force the ComboBox to refresh itself.
|
||||
const auto selectedIndex{ ColorSchemeComboBox().SelectedIndex() };
|
||||
ColorSchemeComboBox().SelectedIndex((selectedIndex + 1) % ColorSchemeList().Size());
|
||||
ColorSchemeComboBox().SelectedIndex(selectedIndex);
|
||||
}
|
||||
|
||||
// Function Description:
|
||||
// - Updates the currently modifiable color table based on the given current color scheme.
|
||||
// Arguments:
|
||||
|
|
|
@ -27,17 +27,28 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
|
||||
void ColorSchemeSelectionChanged(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Controls::SelectionChangedEventArgs const& args);
|
||||
void ColorPickerChanged(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Controls::ColorChangedEventArgs const& args);
|
||||
void AddNew_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e);
|
||||
|
||||
void Rename_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e);
|
||||
void RenameAccept_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e);
|
||||
void RenameCancel_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e);
|
||||
void NameBox_PreviewKeyDown(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Input::KeyRoutedEventArgs const& e);
|
||||
|
||||
bool CanDeleteCurrentScheme() const;
|
||||
void DeleteConfirmation_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e);
|
||||
|
||||
GETSET_PROPERTY(Editor::ColorSchemesPageNavigationState, State, nullptr);
|
||||
GETSET_PROPERTY(Windows::Foundation::Collections::IObservableVector<winrt::Microsoft::Terminal::Settings::Editor::ColorTableEntry>, CurrentColorTable, nullptr);
|
||||
GETSET_PROPERTY(Windows::Foundation::Collections::IObservableVector<winrt::hstring>, ColorSchemeList, nullptr);
|
||||
GETSET_PROPERTY(Windows::Foundation::Collections::IObservableVector<Model::ColorScheme>, ColorSchemeList, nullptr);
|
||||
|
||||
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
|
||||
OBSERVABLE_GETSET_PROPERTY(winrt::Microsoft::Terminal::Settings::Model::ColorScheme, CurrentColorScheme, _PropertyChangedHandlers, nullptr);
|
||||
OBSERVABLE_GETSET_PROPERTY(bool, IsRenaming, _PropertyChangedHandlers, nullptr);
|
||||
|
||||
private:
|
||||
void _UpdateColorTable(const winrt::Microsoft::Terminal::Settings::Model::ColorScheme& colorScheme);
|
||||
void _UpdateColorSchemeList();
|
||||
void _RenameCurrentScheme(hstring newName);
|
||||
};
|
||||
|
||||
struct ColorTableEntry : ColorTableEntryT<ColorTableEntry>
|
||||
|
|
|
@ -13,9 +13,12 @@ namespace Microsoft.Terminal.Settings.Editor
|
|||
ColorSchemes();
|
||||
ColorSchemesPageNavigationState State { get; };
|
||||
|
||||
Boolean CanDeleteCurrentScheme { get; };
|
||||
Boolean IsRenaming { get; };
|
||||
|
||||
Microsoft.Terminal.Settings.Model.ColorScheme CurrentColorScheme { get; };
|
||||
Windows.Foundation.Collections.IObservableVector<ColorTableEntry> CurrentColorTable;
|
||||
Windows.Foundation.Collections.IObservableVector<String> ColorSchemeList { get; };
|
||||
Windows.Foundation.Collections.IObservableVector<Microsoft.Terminal.Settings.Model.ColorScheme> ColorSchemeList { get; };
|
||||
}
|
||||
|
||||
[default_interface] runtimeclass ColorTableEntry : Windows.UI.Xaml.Data.INotifyPropertyChanged
|
||||
|
|
|
@ -5,6 +5,7 @@ the MIT License. See LICENSE in the project root for license information. -->
|
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:Microsoft.Terminal.Settings.Editor"
|
||||
xmlns:model="using:Microsoft.Terminal.Settings.Model"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
@ -15,8 +16,8 @@ the MIT License. See LICENSE in the project root for license information. -->
|
|||
<ResourceDictionary Source="CommonResources.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Thickness x:Key="ColorSchemesStandardControlMargin">10,0,0,20</Thickness>
|
||||
|
||||
<Thickness x:Key="ColorSchemesStandardControlMargin">0,0,10,20</Thickness>
|
||||
|
||||
<Style x:Key="ColorStackPanelStyle" TargetType="StackPanel">
|
||||
<Setter Property="Margin" Value="{StaticResource ColorSchemesStandardControlMargin}"/>
|
||||
<Setter Property="Height" Value="59"/>
|
||||
|
@ -42,32 +43,85 @@ the MIT License. See LICENSE in the project root for license information. -->
|
|||
|
||||
<local:ColorToBrushConverter x:Key="ColorToBrushConverter"/>
|
||||
<local:ColorToHexConverter x:Key="ColorToHexConverter"/>
|
||||
<local:InvertedBooleanToVisibilityConverter x:Key="InvertedBooleanToVisibilityConverter"/>
|
||||
</ResourceDictionary>
|
||||
</Page.Resources>
|
||||
|
||||
<ScrollViewer>
|
||||
<Grid>
|
||||
<Grid Margin="{StaticResource StandardIndentMargin}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*" MaxWidth="480"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!--Select a color scheme-->
|
||||
<ComboBox x:Name="ColorSchemeComboBox"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
SelectedIndex="0"
|
||||
ItemsSource="{x:Bind ColorSchemeList, Mode=OneWay}"
|
||||
SelectionChanged="ColorSchemeSelectionChanged"
|
||||
Style="{StaticResource ComboBoxSettingStyle}"
|
||||
Margin="{StaticResource ColorSchemesStandardControlMargin}"/>
|
||||
<!--Select Color and Add New Button-->
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Margin="{StaticResource StandardControlSpacing}">
|
||||
|
||||
<!-- Color Table -->
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Visibility="{x:Bind IsRenaming, Converter={StaticResource InvertedBooleanToVisibilityConverter}, Mode=OneWay}">
|
||||
<!--Select a color scheme-->
|
||||
<ComboBox x:Name="ColorSchemeComboBox"
|
||||
SelectedIndex="0"
|
||||
ItemsSource="{x:Bind ColorSchemeList, Mode=OneWay}"
|
||||
SelectionChanged="ColorSchemeSelectionChanged"
|
||||
Style="{StaticResource ComboBoxSettingStyle}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="model:ColorScheme">
|
||||
<TextBlock Text="{x:Bind Name, Mode=OneWay}"/>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<!--Rename Button-->
|
||||
<!--Bind IsEnabled to prevent a the color scheme from returning from the dead-->
|
||||
<Button x:Uid="Rename"
|
||||
Style="{StaticResource BrowseButtonStyle}"
|
||||
Click="Rename_Click"
|
||||
IsEnabled="{x:Bind CanDeleteCurrentScheme, Mode=OneWay}">
|
||||
<FontIcon Glyph=""/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Visibility="{x:Bind IsRenaming, Mode=OneWay}">
|
||||
<TextBox x:Name="NameBox"
|
||||
Style="{StaticResource TextBoxSettingStyle}"
|
||||
PreviewKeyDown="NameBox_PreviewKeyDown"/>
|
||||
<Button x:Uid="RenameAccept"
|
||||
Style="{StaticResource AccentBrowseButtonStyle}"
|
||||
Click="RenameAccept_Click">
|
||||
<FontIcon Glyph=""/>
|
||||
</Button>
|
||||
<Button x:Uid="RenameCancel"
|
||||
Style="{StaticResource BrowseButtonStyle}"
|
||||
Click="RenameCancel_Click">
|
||||
<FontIcon Glyph=""/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<!--Add new button-->
|
||||
<Button Click="AddNew_Click"
|
||||
Style="{StaticResource BrowseButtonStyle}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<FontIcon Glyph=""
|
||||
FontSize="15"/>
|
||||
<TextBlock x:Uid="ColorScheme_AddNewButton"
|
||||
Margin="10,0,0,0"
|
||||
FontSize="15"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Color Table (Left Column)-->
|
||||
<ItemsControl x:Name="ColorTableControl"
|
||||
ItemsSource="{x:Bind CurrentColorTable, Mode=OneWay}"
|
||||
Grid.Row="1"
|
||||
|
@ -98,8 +152,8 @@ the MIT License. See LICENSE in the project root for license information. -->
|
|||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
<!-- Additional Colors -->
|
||||
<ItemsControl Grid.Row="2"
|
||||
<!-- Additional Colors (Right Column) -->
|
||||
<ItemsControl Grid.Row="1"
|
||||
Grid.Column="1">
|
||||
<StackPanel Style="{StaticResource ColorStackPanelStyle}">
|
||||
<TextBlock x:Uid="ColorScheme_Foreground"
|
||||
|
@ -149,6 +203,71 @@ the MIT License. See LICENSE in the project root for license information. -->
|
|||
</Button>
|
||||
</StackPanel>
|
||||
</ItemsControl>
|
||||
|
||||
<!--Delete Button-->
|
||||
<StackPanel Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Margin="{StaticResource StandardControlSpacing}">
|
||||
<Button x:Name="DeleteButton"
|
||||
Style="{StaticResource BaseButtonStyle}"
|
||||
IsEnabled="{x:Bind CanDeleteCurrentScheme, Mode=OneWay}"
|
||||
Margin="0,0,0,10">
|
||||
<Button.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary x:Key="Light">
|
||||
<SolidColorBrush x:Key="ButtonBackground" Color="Firebrick"/>
|
||||
<SolidColorBrush x:Key="ButtonBackgroundPointerOver" Color="#C23232"/>
|
||||
<SolidColorBrush x:Key="ButtonBackgroundPressed" Color="#A21212"/>
|
||||
<SolidColorBrush x:Key="ButtonForeground" Color="White"/>
|
||||
<SolidColorBrush x:Key="ButtonForegroundPointerOver" Color="White"/>
|
||||
<SolidColorBrush x:Key="ButtonForegroundPressed" Color="White"/>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="Dark">
|
||||
<SolidColorBrush x:Key="ButtonBackground" Color="Firebrick"/>
|
||||
<SolidColorBrush x:Key="ButtonBackgroundPointerOver" Color="#C23232"/>
|
||||
<SolidColorBrush x:Key="ButtonBackgroundPressed" Color="#A21212"/>
|
||||
<SolidColorBrush x:Key="ButtonForeground" Color="White"/>
|
||||
<SolidColorBrush x:Key="ButtonForegroundPointerOver" Color="White"/>
|
||||
<SolidColorBrush x:Key="ButtonForegroundPressed" Color="White"/>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="HighContrast">
|
||||
<SolidColorBrush x:Key="ButtonBackground" Color="{ThemeResource SystemColorButtonFaceColor}"/>
|
||||
<SolidColorBrush x:Key="ButtonBackgroundPointerOver" Color="{ThemeResource SystemColorHighlightColor}"/>
|
||||
<SolidColorBrush x:Key="ButtonBackgroundPressed" Color="{ThemeResource SystemColorHighlightColor}"/>
|
||||
<SolidColorBrush x:Key="ButtonForeground" Color="{ThemeResource SystemColorButtonTextColor}"/>
|
||||
<SolidColorBrush x:Key="ButtonForegroundPointerOver" Color="{ThemeResource SystemColorHighlightTextColor}"/>
|
||||
<SolidColorBrush x:Key="ButtonForegroundPressed" Color="{ThemeResource SystemColorHighlightTextColor}"/>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Button.Resources>
|
||||
<Button.Content>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<FontIcon Glyph=""
|
||||
FontSize="{StaticResource StandardFontSize}"/>
|
||||
<TextBlock x:Uid="ColorScheme_DeleteButton"
|
||||
FontSize="{StaticResource StandardFontSize}"
|
||||
Margin="10,0,0,0"/>
|
||||
</StackPanel>
|
||||
</Button.Content>
|
||||
<Button.Flyout>
|
||||
<Flyout>
|
||||
<StackPanel>
|
||||
<TextBlock x:Uid="ColorScheme_DeleteConfirmationMessage"
|
||||
Style="{StaticResource CustomFlyoutTextStyle}"/>
|
||||
<Button x:Uid="ColorScheme_DeleteConfirmationButton"
|
||||
Style="{StaticResource BaseButtonStyle}"
|
||||
Click="DeleteConfirmation_Click"/>
|
||||
</StackPanel>
|
||||
</Flyout>
|
||||
</Button.Flyout>
|
||||
</Button>
|
||||
<TextBlock x:Name="DeleteButtonDisclaimer"
|
||||
Style="{StaticResource DisclaimerStyle}"
|
||||
VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Page>
|
||||
|
|
|
@ -5,12 +5,13 @@
|
|||
|
||||
<x:Double x:Key="StandardFontSize">15.0</x:Double>
|
||||
<Thickness x:Key="StandardIndentMargin">20,0,0,0</Thickness>
|
||||
<x:Double x:Key="StandardBoxMinWidth">300</x:Double>
|
||||
<Thickness x:Key="StandardControlSpacing">0,0,0,20</Thickness>
|
||||
<x:Double x:Key="StandardBoxMinWidth">200</x:Double>
|
||||
|
||||
<!-- This is for easier transition to the SettingsContainer control.
|
||||
The SettingsContainer will wrap a setting with inheritance UI.-->
|
||||
<Style x:Key="SettingContainerStyle" TargetType="ContentPresenter">
|
||||
<Setter Property="Padding" Value="0,0,0,20"/>
|
||||
<Setter Property="Padding" Value="{StaticResource StandardControlSpacing}"/>
|
||||
</Style>
|
||||
|
||||
<!--Used to stack a group of settings-->
|
||||
|
@ -63,6 +64,20 @@
|
|||
<Setter Property="Margin" Value="0,20,0,10"/>
|
||||
</Style>
|
||||
|
||||
<!--Used for disclaimers-->
|
||||
<Style x:Key="DisclaimerStyle" TargetType="TextBlock">
|
||||
<Setter Property="FontSize" Value="{StaticResource StandardFontSize}"/>
|
||||
<Setter Property="FontStyle" Value="Italic"/>
|
||||
<Setter Property="TextWrapping" Value="WrapWholeWords"/>
|
||||
</Style>
|
||||
|
||||
<!--Used for flyout messages-->
|
||||
<Style x:Key="CustomFlyoutTextStyle" TargetType="TextBlock" BasedOn="{StaticResource BaseTextBlockStyle}">
|
||||
<Setter Property="FontSize" Value="{StaticResource StandardFontSize}"/>
|
||||
<Setter Property="FontWeight" Value="Bold"/>
|
||||
<Setter Property="Margin" Value="0,0,0,12"/>
|
||||
</Style>
|
||||
|
||||
<!--Number Box-->
|
||||
<Style x:Key="NumberBoxSettingStyle" TargetType="muxc:NumberBox">
|
||||
<Setter Property="FontSize" Value="{StaticResource StandardFontSize}"/>
|
||||
|
@ -74,6 +89,7 @@
|
|||
<!--Button-Related Styling-->
|
||||
<Style x:Key="BaseButtonStyle" TargetType="Button" BasedOn="{StaticResource DefaultButtonStyle}">
|
||||
<Setter Property="FontSize" Value="{StaticResource StandardFontSize}"/>
|
||||
<Setter Property="ToolTipService.Placement" Value="Mouse"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="BrowseButtonStyle" TargetType="Button" BasedOn="{StaticResource BaseButtonStyle}">
|
||||
|
@ -81,6 +97,13 @@
|
|||
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="AccentBrowseButtonStyle" TargetType="Button" BasedOn="{StaticResource AccentButtonStyle}">
|
||||
<Setter Property="FontSize" Value="{StaticResource StandardFontSize}"/>
|
||||
<Setter Property="ToolTipService.Placement" Value="Mouse"/>
|
||||
<Setter Property="Margin" Value="10,0,0,0"/>
|
||||
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||
</Style>
|
||||
|
||||
<!--Slider-Related Styling-->
|
||||
<Style x:Key="SliderSettingStyle" TargetType="Slider" BasedOn="{StaticResource DefaultSliderStyle}">
|
||||
<Setter Property="FontSize" Value="{StaticResource StandardFontSize}"/>
|
||||
|
@ -105,5 +128,4 @@
|
|||
<Setter Property="Width" Value="300"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#include "pch.h"
|
||||
#include "InvertedBooleanToVisibilityConverter.h"
|
||||
#include "InvertedBooleanToVisibilityConverter.g.cpp"
|
||||
|
||||
using namespace winrt::Windows;
|
||||
using namespace winrt::Windows::UI::Xaml;
|
||||
|
||||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
{
|
||||
Foundation::IInspectable InvertedBooleanToVisibilityConverter::Convert(Foundation::IInspectable const& value,
|
||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
||||
Foundation::IInspectable const& /* parameter */,
|
||||
hstring const& /* language */)
|
||||
{
|
||||
return winrt::box_value(winrt::unbox_value<bool>(value) ? Visibility::Collapsed : Visibility::Visible);
|
||||
}
|
||||
|
||||
Foundation::IInspectable InvertedBooleanToVisibilityConverter::ConvertBack(Foundation::IInspectable const& /*value*/,
|
||||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
||||
Foundation::IInspectable const& /*parameter*/,
|
||||
hstring const& /* language */)
|
||||
{
|
||||
throw hresult_not_implemented();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "InvertedBooleanToVisibilityConverter.g.h"
|
||||
#include "Utils.h"
|
||||
|
||||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
{
|
||||
struct InvertedBooleanToVisibilityConverter : InvertedBooleanToVisibilityConverterT<InvertedBooleanToVisibilityConverter>
|
||||
{
|
||||
InvertedBooleanToVisibilityConverter() = default;
|
||||
|
||||
Windows::Foundation::IInspectable Convert(Windows::Foundation::IInspectable const& value,
|
||||
Windows::UI::Xaml::Interop::TypeName const& targetType,
|
||||
Windows::Foundation::IInspectable const& parameter,
|
||||
hstring const& language);
|
||||
|
||||
Windows::Foundation::IInspectable ConvertBack(Windows::Foundation::IInspectable const& value,
|
||||
Windows::UI::Xaml::Interop::TypeName const& targetType,
|
||||
Windows::Foundation::IInspectable const& parameter,
|
||||
hstring const& language);
|
||||
};
|
||||
}
|
||||
|
||||
namespace winrt::Microsoft::Terminal::Settings::Editor::factory_implementation
|
||||
{
|
||||
BASIC_FACTORY(InvertedBooleanToVisibilityConverter);
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Microsoft.Terminal.Settings.Editor
|
||||
{
|
||||
runtimeclass InvertedBooleanToVisibilityConverter : [default] Windows.UI.Xaml.Data.IValueConverter
|
||||
{
|
||||
InvertedBooleanToVisibilityConverter();
|
||||
};
|
||||
}
|
|
@ -10,6 +10,7 @@
|
|||
#include "Profiles.h"
|
||||
#include "GlobalAppearance.h"
|
||||
#include "ColorSchemes.h"
|
||||
#include "..\types\inc\utils.hpp"
|
||||
|
||||
#include <LibraryResources.h>
|
||||
|
||||
|
@ -197,7 +198,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
else if (const auto profile = clickedItemContainer.Tag().try_as<Editor::ProfileViewModel>())
|
||||
{
|
||||
// Navigate to a page with the given profile
|
||||
contentFrame().Navigate(xaml_typename<Editor::Profiles>(), winrt::make<ProfilePageNavigationState>(profile, _settingsClone.GlobalSettings().ColorSchemes(), *this));
|
||||
_Navigate(profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -218,7 +219,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
}
|
||||
else if (clickedItemTag == globalProfileTag)
|
||||
{
|
||||
contentFrame().Navigate(xaml_typename<Editor::Profiles>(), winrt::make<ProfilePageNavigationState>(_viewModelForProfile(_settingsClone.ProfileDefaults()), _settingsClone.GlobalSettings().ColorSchemes(), *this));
|
||||
auto profileVM{ _viewModelForProfile(_settingsClone.ProfileDefaults()) };
|
||||
profileVM.IsBaseLayer(true);
|
||||
contentFrame().Navigate(xaml_typename<Editor::Profiles>(), winrt::make<ProfilePageNavigationState>(profileVM, _settingsClone.GlobalSettings().ColorSchemes(), *this));
|
||||
}
|
||||
else if (clickedItemTag == colorSchemesTag)
|
||||
{
|
||||
|
@ -230,6 +233,16 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
}
|
||||
}
|
||||
|
||||
void MainPage::_Navigate(const Editor::ProfileViewModel& profile)
|
||||
{
|
||||
auto state{ winrt::make<ProfilePageNavigationState>(profile, _settingsClone.GlobalSettings().ColorSchemes(), *this) };
|
||||
|
||||
// Add an event handler for when the user wants to delete a profile.
|
||||
state.DeleteProfile({ this, &MainPage::_DeleteProfile });
|
||||
|
||||
contentFrame().Navigate(xaml_typename<Editor::Profiles>(), state);
|
||||
}
|
||||
|
||||
void MainPage::OpenJsonTapped(IInspectable const& /*sender*/, Windows::UI::Xaml::Input::TappedRoutedEventArgs const& /*args*/)
|
||||
{
|
||||
const CoreWindow window = CoreWindow::GetForCurrentThread();
|
||||
|
@ -297,7 +310,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
|
||||
// Select and navigate to the new profile
|
||||
SettingsNav().SelectedItem(navItem);
|
||||
contentFrame().Navigate(xaml_typename<Editor::Profiles>(), winrt::make<ProfilePageNavigationState>(profileViewModel, _settingsClone.GlobalSettings().ColorSchemes(), *this));
|
||||
_Navigate(profileViewModel);
|
||||
}
|
||||
|
||||
MUX::Controls::NavigationViewItem MainPage::_CreateProfileNavViewItem(const Editor::ProfileViewModel& profile)
|
||||
|
@ -313,4 +326,31 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
|
||||
return profileNavItem;
|
||||
}
|
||||
|
||||
void MainPage::_DeleteProfile(const IInspectable /*sender*/, const Editor::DeleteProfileEventArgs& args)
|
||||
{
|
||||
// Delete profile from settings model
|
||||
const auto guid{ args.ProfileGuid() };
|
||||
auto profileList{ _settingsClone.AllProfiles() };
|
||||
for (uint32_t i = 0; i < profileList.Size(); ++i)
|
||||
{
|
||||
if (profileList.GetAt(i).Guid() == guid)
|
||||
{
|
||||
profileList.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// remove selected item
|
||||
uint32_t index;
|
||||
auto selectedItem{ SettingsNav().SelectedItem() };
|
||||
auto menuItems{ SettingsNav().MenuItems() };
|
||||
menuItems.IndexOf(selectedItem, index);
|
||||
menuItems.RemoveAt(index);
|
||||
|
||||
// navigate to the profile next to this one
|
||||
const auto newSelectedItem{ menuItems.GetAt(index < menuItems.Size() - 1 ? index : index - 1) };
|
||||
SettingsNav().SelectedItem(newSelectedItem);
|
||||
_Navigate(newSelectedItem.try_as<MUX::Controls::NavigationViewItem>().Tag().try_as<Editor::ProfileViewModel>());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,9 +35,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
|
||||
void _InitializeProfilesList();
|
||||
void _CreateAndNavigateToNewProfile(const uint32_t index);
|
||||
winrt::Microsoft::UI::Xaml::Controls::NavigationViewItem _CreateProfileNavViewItem(const ProfileViewModel& profile);
|
||||
winrt::Microsoft::UI::Xaml::Controls::NavigationViewItem _CreateProfileNavViewItem(const Editor::ProfileViewModel& profile);
|
||||
void _DeleteProfile(const Windows::Foundation::IInspectable sender, const Editor::DeleteProfileEventArgs& args);
|
||||
|
||||
void _Navigate(hstring clickedItemTag);
|
||||
void _Navigate(const Editor::ProfileViewModel& profile);
|
||||
void _RefreshCurrentPage();
|
||||
};
|
||||
}
|
||||
|
|
|
@ -44,6 +44,9 @@
|
|||
<ClInclude Include="FontWeightConverter.h">
|
||||
<DependentUpon>FontWeightConverter.idl</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="InvertedBooleanToVisibilityConverter.h">
|
||||
<DependentUpon>InvertedBooleanToVisibilityConverter.idl</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PercentageConverter.h">
|
||||
<DependentUpon>PercentageConverter.idl</DependentUpon>
|
||||
</ClInclude>
|
||||
|
@ -114,6 +117,9 @@
|
|||
<ClCompile Include="FontWeightConverter.cpp">
|
||||
<DependentUpon>FontWeightConverter.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="InvertedBooleanToVisibilityConverter.cpp">
|
||||
<DependentUpon>InvertedBooleanToVisibilityConverter.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="PercentageConverter.cpp">
|
||||
<DependentUpon>PercentageConverter.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
|
@ -151,6 +157,7 @@
|
|||
<Midl Include="ColorToBrushConverter.idl" />
|
||||
<Midl Include="ColorToHexConverter.idl" />
|
||||
<Midl Include="FontWeightConverter.idl" />
|
||||
<Midl Include="InvertedBooleanToVisibilityConverter.idl" />
|
||||
<Midl Include="PercentageConverter.idl" />
|
||||
<Midl Include="EnumEntry.idl" />
|
||||
<Midl Include="GlobalAppearance.idl">
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
<Midl Include="FontWeightConverter.idl">
|
||||
<Filter>Converters</Filter>
|
||||
</Midl>
|
||||
<Midl Include="InvertedBooleanToVisibilityConverter.idl">
|
||||
<Filter>Converters</Filter>
|
||||
</Midl>
|
||||
<Midl Include="PercentageConverter.idl">
|
||||
<Filter>Converters</Filter>
|
||||
</Midl>
|
||||
|
|
|
@ -10,6 +10,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::Navigation;
|
||||
using namespace winrt::Windows::Foundation;
|
||||
using namespace winrt::Windows::Foundation::Collections;
|
||||
|
@ -18,8 +19,42 @@ using namespace winrt::Windows::Storage::AccessCache;
|
|||
using namespace winrt::Windows::Storage::Pickers;
|
||||
using namespace winrt::Microsoft::Terminal::Settings::Model;
|
||||
|
||||
static const std::array<winrt::guid, 2> InBoxProfileGuids{
|
||||
winrt::guid{ 0x61c54bbd, 0xc2c6, 0x5271, { 0x96, 0xe7, 0x00, 0x9a, 0x87, 0xff, 0x44, 0xbf } }, // Windows Powershell
|
||||
winrt::guid{ 0x0caa0dad, 0x35be, 0x5f56, { 0xa8, 0xff, 0xaf, 0xce, 0xee, 0xaa, 0x61, 0x01 } } // Command Prompt
|
||||
};
|
||||
|
||||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
{
|
||||
bool ProfileViewModel::CanDeleteProfile() const
|
||||
{
|
||||
const auto guid{ Guid() };
|
||||
if (IsBaseLayer())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (std::find(std::begin(InBoxProfileGuids), std::end(InBoxProfileGuids), guid) != std::end(InBoxProfileGuids))
|
||||
{
|
||||
// in-box profile
|
||||
return false;
|
||||
}
|
||||
else if (!Source().empty())
|
||||
{
|
||||
// dynamic profile
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void ProfilePageNavigationState::DeleteProfile()
|
||||
{
|
||||
auto deleteProfileArgs{ winrt::make_self<DeleteProfileEventArgs>(_Profile.Guid()) };
|
||||
_DeleteProfileHandlers(*this, *deleteProfileArgs);
|
||||
}
|
||||
|
||||
Profiles::Profiles() :
|
||||
_ColorSchemeList{ single_threaded_observable_vector<ColorScheme>() }
|
||||
{
|
||||
|
@ -64,6 +99,21 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
{
|
||||
biButton.IsChecked(biButton.Tag().as<int32_t>() == biAlignmentVal);
|
||||
}
|
||||
|
||||
// Set the text disclaimer for the text box
|
||||
hstring disclaimer{};
|
||||
const auto guid{ _State.Profile().Guid() };
|
||||
if (std::find(std::begin(InBoxProfileGuids), std::end(InBoxProfileGuids), guid) != std::end(InBoxProfileGuids))
|
||||
{
|
||||
// load disclaimer for in-box profiles
|
||||
disclaimer = RS_(L"Profile_DeleteButtonDisclaimerInBox");
|
||||
}
|
||||
else if (!_State.Profile().Source().empty())
|
||||
{
|
||||
// load disclaimer for dynamic profiles
|
||||
disclaimer = RS_(L"Profile_DeleteButtonDisclaimerDynamic");
|
||||
}
|
||||
DeleteButtonDisclaimer().Text(disclaimer);
|
||||
}
|
||||
|
||||
ColorScheme Profiles::CurrentColorScheme()
|
||||
|
@ -86,6 +136,12 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
_State.Profile().ColorSchemeName(val.Name());
|
||||
}
|
||||
|
||||
void Profiles::DeleteConfirmation_Click(IInspectable const& /*sender*/, RoutedEventArgs const& /*e*/)
|
||||
{
|
||||
auto state{ winrt::get_self<ProfilePageNavigationState>(_State) };
|
||||
state->DeleteProfile();
|
||||
}
|
||||
|
||||
fire_and_forget Profiles::BackgroundImage_Click(IInspectable const&, RoutedEventArgs const&)
|
||||
{
|
||||
auto lifetime = get_strong();
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "Profiles.g.h"
|
||||
#include "ProfilePageNavigationState.g.h"
|
||||
#include "DeleteProfileEventArgs.g.h"
|
||||
#include "ProfileViewModel.g.h"
|
||||
#include "Utils.h"
|
||||
#include "ViewModelHelpers.h"
|
||||
|
@ -17,6 +18,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
ProfileViewModel(const Model::Profile& profile) :
|
||||
_profile{ profile } {}
|
||||
|
||||
bool CanDeleteProfile() const;
|
||||
GETSET_PROPERTY(bool, IsBaseLayer, false);
|
||||
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_profile, Guid);
|
||||
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_profile, ConnectionType);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, Name);
|
||||
|
@ -60,6 +64,19 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
Model::Profile _profile;
|
||||
};
|
||||
|
||||
struct DeleteProfileEventArgs :
|
||||
public DeleteProfileEventArgsT<DeleteProfileEventArgs>
|
||||
{
|
||||
public:
|
||||
DeleteProfileEventArgs(guid profileGuid) :
|
||||
_ProfileGuid(profileGuid) {}
|
||||
|
||||
guid ProfileGuid() const noexcept { return _ProfileGuid; }
|
||||
|
||||
private:
|
||||
guid _ProfileGuid{};
|
||||
};
|
||||
|
||||
struct ProfilePageNavigationState : ProfilePageNavigationStateT<ProfilePageNavigationState>
|
||||
{
|
||||
public:
|
||||
|
@ -70,9 +87,12 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
{
|
||||
}
|
||||
|
||||
void DeleteProfile();
|
||||
|
||||
Windows::Foundation::Collections::IMapView<hstring, Model::ColorScheme> Schemes() { return _Schemes; }
|
||||
void Schemes(const Windows::Foundation::Collections::IMapView<hstring, Model::ColorScheme>& val) { _Schemes = val; }
|
||||
|
||||
TYPED_EVENT(DeleteProfile, Editor::ProfilePageNavigationState, Editor::DeleteProfileEventArgs);
|
||||
GETSET_PROPERTY(IHostedInWindow, WindowRoot, nullptr);
|
||||
GETSET_PROPERTY(Editor::ProfileViewModel, Profile, nullptr);
|
||||
|
||||
|
@ -95,6 +115,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
fire_and_forget StartingDirectory_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e);
|
||||
fire_and_forget Icon_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e);
|
||||
void BIAlignment_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e);
|
||||
void DeleteConfirmation_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e);
|
||||
|
||||
// CursorShape visibility logic
|
||||
void CursorShape_Changed(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e);
|
||||
|
|
|
@ -10,6 +10,9 @@ namespace Microsoft.Terminal.Settings.Editor
|
|||
{
|
||||
runtimeclass ProfileViewModel : Windows.UI.Xaml.Data.INotifyPropertyChanged
|
||||
{
|
||||
Boolean CanDeleteProfile { get; };
|
||||
Boolean IsBaseLayer;
|
||||
|
||||
OBSERVABLE_PROJECTED_SETTING(String, Name);
|
||||
OBSERVABLE_PROJECTED_SETTING(Guid, Guid);
|
||||
OBSERVABLE_PROJECTED_SETTING(String, Source);
|
||||
|
@ -50,12 +53,19 @@ namespace Microsoft.Terminal.Settings.Editor
|
|||
OBSERVABLE_PROJECTED_SETTING(Microsoft.Terminal.Settings.Model.BellStyle, BellStyle);
|
||||
}
|
||||
|
||||
runtimeclass DeleteProfileEventArgs
|
||||
{
|
||||
Guid ProfileGuid { get; };
|
||||
}
|
||||
|
||||
runtimeclass ProfilePageNavigationState
|
||||
{
|
||||
Windows.Foundation.Collections.IMapView<String, Microsoft.Terminal.Settings.Model.ColorScheme> Schemes;
|
||||
IHostedInWindow WindowRoot; // necessary to send the right HWND into the file picker dialogs.
|
||||
|
||||
ProfileViewModel Profile { get; };
|
||||
|
||||
event Windows.Foundation.TypedEventHandler<ProfilePageNavigationState, DeleteProfileEventArgs> DeleteProfile;
|
||||
};
|
||||
|
||||
[default_interface] runtimeclass Profiles : Windows.UI.Xaml.Controls.Page, Windows.UI.Xaml.Data.INotifyPropertyChanged
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -19,9 +19,8 @@ the MIT License. See LICENSE in the project root for license information. -->
|
|||
<ScrollViewer>
|
||||
<StackPanel Style="{StaticResource SettingsStackStyle}">
|
||||
<TextBlock x:Uid="Globals_RenderingDisclaimer"
|
||||
FontSize="{StaticResource StandardFontSize}"
|
||||
FontStyle="Italic"
|
||||
Margin="0,0,0,20"/>
|
||||
Style="{StaticResource DisclaimerStyle}"
|
||||
Margin="{StaticResource StandardControlSpacing}"/>
|
||||
|
||||
<!--Force Full Repaint-->
|
||||
<ContentPresenter Style="{StaticResource SettingContainerStyle}">
|
||||
|
|
|
@ -722,6 +722,27 @@
|
|||
<data name="Profile_BellStyleVisual.Content" xml:space="preserve">
|
||||
<value>Visual (Flash Taskbar)</value>
|
||||
</data>
|
||||
<data name="ColorScheme_AddNewButton.Text" xml:space="preserve">
|
||||
<value>Add new</value>
|
||||
</data>
|
||||
<data name="ColorScheme_DeleteButton.Text" xml:space="preserve">
|
||||
<value>Delete color scheme</value>
|
||||
</data>
|
||||
<data name="ColorScheme_Name.Header" xml:space="preserve">
|
||||
<value>Name</value>
|
||||
</data>
|
||||
<data name="ColorScheme_Name.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
|
||||
<value>The name of the color scheme.</value>
|
||||
</data>
|
||||
<data name="Profile_DeleteButton.Text" xml:space="preserve">
|
||||
<value>Delete profile</value>
|
||||
</data>
|
||||
<data name="Profile_Name.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
|
||||
<value>The name of the profile that appears in the dropdown.</value>
|
||||
</data>
|
||||
<data name="Profile_Name.Header" xml:space="preserve">
|
||||
<value>Name</value>
|
||||
</data>
|
||||
<data name="Profile_AcrylicHeader.Text" xml:space="preserve">
|
||||
<value>Acrylic</value>
|
||||
</data>
|
||||
|
@ -741,4 +762,40 @@
|
|||
<value>Open your settings.json file. Alt+Click to open your defaults.json file.</value>
|
||||
<comment>{Locked="settings.json"}, {Locked="defaults.json"}</comment>
|
||||
</data>
|
||||
<data name="ColorScheme_DeleteButton.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
|
||||
<value>Delete the current color scheme.</value>
|
||||
</data>
|
||||
<data name="Rename.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
|
||||
<value>Rename</value>
|
||||
</data>
|
||||
<data name="Profile_DeleteButtonDisclaimerInBox" xml:space="preserve">
|
||||
<value>This profile cannot be deleted because it is included by default.</value>
|
||||
</data>
|
||||
<data name="Profile_DeleteButtonDisclaimerDynamic" xml:space="preserve">
|
||||
<value>This profile cannot be deleted because it is automatically generated.</value>
|
||||
</data>
|
||||
<data name="ColorScheme_DeleteButtonDisclaimerInBox" xml:space="preserve">
|
||||
<value>This color scheme cannot be deleted or renamed because it is included by default.</value>
|
||||
</data>
|
||||
<data name="ColorScheme_DeleteConfirmationButton.Content" xml:space="preserve">
|
||||
<value>Yes, delete color scheme</value>
|
||||
</data>
|
||||
<data name="ColorScheme_DeleteConfirmationMessage.Text" xml:space="preserve">
|
||||
<value>Are you sure you want to delete this color scheme?</value>
|
||||
</data>
|
||||
<data name="RenameAccept.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
|
||||
<value>Accept rename</value>
|
||||
</data>
|
||||
<data name="RenameCancel.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
|
||||
<value>Cancel rename</value>
|
||||
</data>
|
||||
<data name="Profile_BaseLayerDisclaimer.Text" xml:space="preserve">
|
||||
<value>Settings defined here will apply to all profiles unless they are overridden by a profile's settings.</value>
|
||||
</data>
|
||||
<data name="Profile_DeleteConfirmationButton.Content" xml:space="preserve">
|
||||
<value>Yes, delete profile</value>
|
||||
</data>
|
||||
<data name="Profile_DeleteConfirmationMessage.Text" xml:space="preserve">
|
||||
<value>Are you sure you want to delete this profile?</value>
|
||||
</data>
|
||||
</root>
|
|
@ -5,6 +5,7 @@
|
|||
#include "ColorScheme.h"
|
||||
#include "DefaultSettings.h"
|
||||
#include "../../types/inc/Utils.hpp"
|
||||
#include "../../types/inc/colorTable.hpp"
|
||||
#include "Utils.h"
|
||||
#include "JsonUtils.h"
|
||||
|
||||
|
@ -41,14 +42,18 @@ static constexpr std::array<std::string_view, 16> TableColors = {
|
|||
};
|
||||
|
||||
ColorScheme::ColorScheme() :
|
||||
_Foreground{ DEFAULT_FOREGROUND_WITH_ALPHA },
|
||||
_Background{ DEFAULT_BACKGROUND_WITH_ALPHA },
|
||||
_SelectionBackground{ DEFAULT_FOREGROUND },
|
||||
_CursorColor{ DEFAULT_CURSOR_COLOR }
|
||||
ColorScheme(L"", DEFAULT_FOREGROUND_WITH_ALPHA, DEFAULT_BACKGROUND_WITH_ALPHA, DEFAULT_CURSOR_COLOR)
|
||||
{
|
||||
Utils::InitializeCampbellColorTable(_table);
|
||||
}
|
||||
|
||||
ColorScheme::ColorScheme(winrt::hstring name, Color defaultFg, Color defaultBg, Color cursorColor) :
|
||||
ColorScheme::ColorScheme(winrt::hstring name) :
|
||||
ColorScheme(name, DEFAULT_FOREGROUND_WITH_ALPHA, DEFAULT_BACKGROUND_WITH_ALPHA, DEFAULT_CURSOR_COLOR)
|
||||
{
|
||||
Utils::InitializeCampbellColorTable(_table);
|
||||
}
|
||||
|
||||
ColorScheme::ColorScheme(winrt::hstring name, COLORREF defaultFg, COLORREF defaultBg, COLORREF cursorColor) :
|
||||
_Name{ name },
|
||||
_Foreground{ defaultFg },
|
||||
_Background{ defaultBg },
|
||||
|
|
|
@ -33,7 +33,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
|||
{
|
||||
public:
|
||||
ColorScheme();
|
||||
ColorScheme(hstring name, Windows::UI::Color defaultFg, Windows::UI::Color defaultBg, Windows::UI::Color cursorColor);
|
||||
ColorScheme(hstring name);
|
||||
ColorScheme(hstring name, COLORREF defaultFg, COLORREF defaultBg, COLORREF cursorColor);
|
||||
com_ptr<ColorScheme> Copy() const;
|
||||
|
||||
static com_ptr<ColorScheme> FromJson(const Json::Value& json);
|
||||
|
@ -60,3 +61,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
|||
friend class SettingsModelLocalTests::ColorSchemeTests;
|
||||
};
|
||||
}
|
||||
|
||||
namespace winrt::Microsoft::Terminal::Settings::Model::factory_implementation
|
||||
{
|
||||
BASIC_FACTORY(ColorScheme);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
namespace Microsoft.Terminal.Settings.Model
|
||||
{
|
||||
[default_interface] runtimeclass ColorScheme {
|
||||
ColorScheme(String name);
|
||||
|
||||
String Name;
|
||||
|
||||
Windows.UI.Color Foreground;
|
||||
|
|
|
@ -334,6 +334,11 @@ void GlobalAppSettings::AddColorScheme(const Model::ColorScheme& scheme)
|
|||
_colorSchemes.Insert(scheme.Name(), scheme);
|
||||
}
|
||||
|
||||
void GlobalAppSettings::RemoveColorScheme(hstring schemeName)
|
||||
{
|
||||
_colorSchemes.TryRemove(schemeName);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Return the warnings that we've collected during parsing the JSON for the
|
||||
// keybindings. It's possible that the user provided keybindings have some
|
||||
|
|
|
@ -40,6 +40,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
|||
|
||||
Windows::Foundation::Collections::IMapView<hstring, Model::ColorScheme> ColorSchemes() noexcept;
|
||||
void AddColorScheme(const Model::ColorScheme& scheme);
|
||||
void RemoveColorScheme(hstring schemeName);
|
||||
|
||||
Model::KeyMapping KeyMap() const noexcept;
|
||||
|
||||
|
|
|
@ -137,6 +137,7 @@ namespace Microsoft.Terminal.Settings.Model
|
|||
|
||||
Windows.Foundation.Collections.IMapView<String, ColorScheme> ColorSchemes();
|
||||
void AddColorScheme(ColorScheme scheme);
|
||||
void RemoveColorScheme(String schemeName);
|
||||
|
||||
KeyMapping KeyMap();
|
||||
|
||||
|
|
|
@ -468,6 +468,13 @@ void Utils::InitializeCampbellColorTable(const gsl::span<COLORREF> table)
|
|||
std::copy(campbellColorTable.begin(), campbellColorTable.end(), table.begin());
|
||||
}
|
||||
|
||||
void Utils::InitializeCampbellColorTable(const gsl::span<til::color> table)
|
||||
{
|
||||
THROW_HR_IF(E_INVALIDARG, table.size() < 16);
|
||||
|
||||
std::copy(campbellColorTable.begin(), campbellColorTable.end(), table.begin());
|
||||
}
|
||||
|
||||
// Function Description:
|
||||
// - Fill the first 16 entries of a given color table with the Campbell color
|
||||
// scheme, in the Windows BGR order.
|
||||
|
|
|
@ -13,6 +13,7 @@ Abstract:
|
|||
namespace Microsoft::Console::Utils
|
||||
{
|
||||
void InitializeCampbellColorTable(const gsl::span<COLORREF> table);
|
||||
void InitializeCampbellColorTable(const gsl::span<til::color> table);
|
||||
void InitializeCampbellColorTableForConhost(const gsl::span<COLORREF> table);
|
||||
void SwapANSIColorOrderForConhost(const gsl::span<COLORREF> table);
|
||||
void Initialize256ColorTable(const gsl::span<COLORREF> table);
|
||||
|
|
Loading…
Reference in a new issue