Skip to content

Commit

Permalink
just use muxc:expander
Browse files Browse the repository at this point in the history
  • Loading branch information
PankajBhojwani committed Nov 9, 2021
1 parent f3fd857 commit 13bbcbf
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 450 deletions.
8 changes: 6 additions & 2 deletions src/cascadia/TerminalSettingsEditor/Appearances.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
ClearSettingValue="{x:Bind Appearance.ClearCursorShape}"
HasSettingValue="{x:Bind Appearance.HasCursorShape, Mode=OneWay}"
SettingOverrideSource="{x:Bind Appearance.CursorShapeOverrideSource, Mode=OneWay}"
Style="{StaticResource AlternativeSettingContainerStyle}">
Style="{StaticResource ExpanderSettingContainerStyle}">
<muxc:RadioButtons AutomationProperties.AccessibilityView="Content"
ItemTemplate="{StaticResource EnumRadioButtonTemplate}"
ItemsSource="{x:Bind CursorShapeList, Mode=OneWay}"
Expand Down Expand Up @@ -210,6 +210,8 @@
<!-- Background Image -->
<local:SettingContainer x:Name="BackgroundImageContainer"
x:Uid="Profile_BackgroundImage"
Style="{StaticResource ExpanderSettingContainerStyle}"
CurrentValue="{x:Bind Appearance.BackgroundImagePath, Mode=OneWay}"
ClearSettingValue="{x:Bind Appearance.ClearBackgroundImagePath}"
HasSettingValue="{x:Bind Appearance.HasBackgroundImagePath, Mode=OneWay}"
SettingOverrideSource="{x:Bind Appearance.BackgroundImagePathOverrideSource, Mode=OneWay}">
Expand All @@ -234,6 +236,7 @@
<local:SettingContainer x:Uid="Profile_BackgroundImageStretchMode"
ClearSettingValue="{x:Bind Appearance.ClearBackgroundImageStretchMode}"
HasSettingValue="{x:Bind Appearance.HasBackgroundImageStretchMode, Mode=OneWay}"
Style="{StaticResource ExpanderSettingContainerStyle}"
SettingOverrideSource="{x:Bind Appearance.BackgroundImageStretchModeOverrideSource, Mode=OneWay}"
Visibility="{x:Bind Appearance.BackgroundImageSettingsVisible, Mode=OneWay}">
<muxc:RadioButtons AutomationProperties.AccessibilityView="Content"
Expand All @@ -245,6 +248,7 @@
<!-- Background Image Alignment -->
<local:SettingContainer x:Uid="Profile_BackgroundImageAlignment"
ClearSettingValue="{x:Bind Appearance.ClearBackgroundImageAlignment}"
Style="{StaticResource ExpanderSettingContainerStyle}"
HasSettingValue="{x:Bind Appearance.HasBackgroundImageAlignment, Mode=OneWay}"
SettingOverrideSource="{x:Bind Appearance.BackgroundImageAlignmentOverrideSource, Mode=OneWay}"
Visibility="{x:Bind Appearance.BackgroundImageSettingsVisible, Mode=OneWay}">
Expand Down Expand Up @@ -451,7 +455,7 @@
ClearSettingValue="{x:Bind Appearance.ClearIntenseTextStyle}"
HasSettingValue="{x:Bind Appearance.HasIntenseTextStyle, Mode=OneWay}"
SettingOverrideSource="{x:Bind Appearance.IntenseTextStyleOverrideSource, Mode=OneWay}"
Style="{StaticResource AlternativeSettingContainerStyle}">
Style="{StaticResource ExpanderSettingContainerStyle}">
<muxc:RadioButtons AutomationProperties.AccessibilityView="Content"
ItemTemplate="{StaticResource EnumRadioButtonTemplate}"
ItemsSource="{x:Bind IntenseTextStyleList, Mode=OneWay}"
Expand Down
4 changes: 2 additions & 2 deletions src/cascadia/TerminalSettingsEditor/GlobalAppearance.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

<!-- Theme -->
<local:SettingContainer x:Uid="Globals_Theme"
Style="{StaticResource AlternativeSettingContainerStyle}">
Style="{StaticResource ExpanderSettingContainerStyle}">
<muxc:RadioButtons AutomationProperties.AccessibilityView="Content"
ItemTemplate="{StaticResource EnumRadioButtonTemplate}"
ItemsSource="{x:Bind ThemeList, Mode=OneWay}"
Expand Down Expand Up @@ -75,7 +75,7 @@

<!-- Tab Width Mode -->
<local:SettingContainer x:Uid="Globals_TabWidthMode"
Style="{StaticResource AlternativeSettingContainerStyle}">
Style="{StaticResource ExpanderSettingContainerStyle}">
<muxc:RadioButtons AutomationProperties.AccessibilityView="Content"
ItemTemplate="{StaticResource EnumRadioButtonTemplate}"
ItemsSource="{x:Bind TabWidthModeList, Mode=OneWay}"
Expand Down
8 changes: 5 additions & 3 deletions src/cascadia/TerminalSettingsEditor/Interaction.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

<!-- Copy Format -->
<local:SettingContainer x:Uid="Globals_CopyFormat"
Style="{StaticResource AlternativeSettingContainerStyle}">
Style="{StaticResource ExpanderSettingContainerStyle}">
<muxc:RadioButtons AutomationProperties.AccessibilityView="Content"
ItemTemplate="{StaticResource EnumRadioButtonTemplate}"
ItemsSource="{x:Bind CopyFormatList, Mode=OneWay}"
Expand All @@ -51,7 +51,9 @@
</local:SettingContainer>

<!-- Word Delimiters -->
<local:SettingContainer x:Uid="Globals_WordDelimiters">
<local:SettingContainer x:Uid="Globals_WordDelimiters"
Style="{StaticResource ExpanderSettingContainerStyle}"
CurrentValue="{x:Bind State.Globals.WordDelimiters, Mode=OneWay}">
<TextBox IsSpellCheckEnabled="False"
Style="{StaticResource TextBoxSettingStyle}"
Text="{x:Bind State.Globals.WordDelimiters, Mode=TwoWay}" />
Expand All @@ -64,7 +66,7 @@

<!-- Tab Switcher Mode -->
<local:SettingContainer x:Uid="Globals_TabSwitcherMode"
Style="{StaticResource AlternativeSettingContainerStyle}">
Style="{StaticResource ExpanderSettingContainerStyle}">
<muxc:RadioButtons AutomationProperties.AccessibilityView="Content"
ItemTemplate="{StaticResource EnumRadioButtonTemplate}"
ItemsSource="{x:Bind TabSwitcherModeList}"
Expand Down
9 changes: 4 additions & 5 deletions src/cascadia/TerminalSettingsEditor/Launch.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
<StackPanel>
<StackPanel Style="{StaticResource SettingsStackStyle}">
<!-- Default Profile -->
<local:SettingContainer x:Name="zzzknn"
x:Uid="Globals_DefaultProfile">
<local:SettingContainer x:Uid="Globals_DefaultProfile">
<ComboBox x:Name="DefaultProfile"
ItemsSource="{x:Bind DefaultProfiles}"
SelectedItem="{x:Bind CurrentDefaultProfile, Mode=TwoWay}"
Expand Down Expand Up @@ -136,7 +135,7 @@
<!-- First Window Behavior -->
<local:SettingContainer x:Uid="Globals_FirstWindowPreference"
Visibility="{x:Bind ShowFirstWindowPreference}"
Style="{StaticResource AlternativeSettingContainerStyle}">
Style="{StaticResource ExpanderSettingContainerStyle}">
<muxc:RadioButtons AutomationProperties.AccessibilityView="Content"
ItemTemplate="{StaticResource EnumRadioButtonTemplate}"
ItemsSource="{x:Bind FirstWindowPreferenceList}"
Expand All @@ -147,7 +146,7 @@
<!-- Launch Mode -->
<local:SettingContainer x:Name="Globals_LaunchMode"
x:Uid="Globals_LaunchMode"
Style="{StaticResource AlternativeSettingContainerStyle}">
Style="{StaticResource ExpanderSettingContainerStyle}">
<muxc:RadioButtons AutomationProperties.AccessibilityView="Content"
ItemTemplate="{StaticResource EnumRadioButtonTemplate}"
ItemsSource="{x:Bind LaunchModeList}"
Expand All @@ -156,7 +155,7 @@

<!-- Launch Mode -->
<local:SettingContainer x:Uid="Globals_WindowingBehavior"
Style="{StaticResource AlternativeSettingContainerStyle}">
Style="{StaticResource ExpanderSettingContainerStyle}">
<muxc:RadioButtons AutomationProperties.AccessibilityView="Content"
ItemTemplate="{StaticResource EnumRadioButtonTemplate}"
ItemsSource="{x:Bind WindowingBehaviorList}"
Expand Down
18 changes: 14 additions & 4 deletions src/cascadia/TerminalSettingsEditor/Profiles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
so the name will always be overridden.
-->
<local:SettingContainer x:Uid="Profile_Name"
Style="{StaticResource ExpanderSettingContainerStyle}"
CurrentValue="{x:Bind State.Profile.Name, Mode=OneWay}"
Visibility="{x:Bind local:Converters.InvertedBooleanToVisibility(State.Profile.IsBaseLayer), Mode=OneWay}">
<TextBox Style="{StaticResource TextBoxSettingStyle}"
Text="{x:Bind State.Profile.Name, Mode=TwoWay}" />
Expand All @@ -77,6 +79,8 @@
ClearSettingValue="{x:Bind State.Profile.ClearCommandline}"
HasSettingValue="{x:Bind State.Profile.HasCommandline, Mode=OneWay}"
SettingOverrideSource="{x:Bind State.Profile.CommandlineOverrideSource, Mode=OneWay}"
Style="{StaticResource ExpanderSettingContainerStyle}"
CurrentValue="{x:Bind State.Profile.Commandline, Mode=OneWay}"
Visibility="{x:Bind local:Converters.InvertedBooleanToVisibility(State.Profile.IsBaseLayer), Mode=OneWay}">
<StackPanel Orientation="Horizontal">
<TextBox x:Uid="Profile_CommandlineBox"
Expand All @@ -92,6 +96,8 @@
<!-- Starting Directory -->
<local:SettingContainer x:Name="StartingDirectoryContainer"
x:Uid="Profile_StartingDirectory"
Style="{StaticResource ExpanderSettingContainerStyle}"
CurrentValue="{x:Bind State.Profile.StartingDirectory, Mode=OneWay}"
ClearSettingValue="{x:Bind State.Profile.ClearStartingDirectory}"
HasSettingValue="{x:Bind State.Profile.HasStartingDirectory, Mode=OneWay}"
SettingOverrideSource="{x:Bind State.Profile.StartingDirectoryOverrideSource, Mode=OneWay}">
Expand All @@ -118,6 +124,8 @@
<local:SettingContainer x:Uid="Profile_Icon"
ClearSettingValue="{x:Bind State.Profile.ClearIcon}"
HasSettingValue="{x:Bind State.Profile.HasIcon, Mode=OneWay}"
Style="{StaticResource ExpanderSettingContainerStyle}"
CurrentValue="{x:Bind State.Profile.Icon, Mode=OneWay}"
SettingOverrideSource="{x:Bind State.Profile.IconOverrideSource, Mode=OneWay}">
<StackPanel Orientation="Horizontal">
<TextBox x:Uid="Profile_IconBox"
Expand All @@ -134,6 +142,8 @@
<!-- Tab Title -->
<local:SettingContainer x:Uid="Profile_TabTitle"
ClearSettingValue="{x:Bind State.Profile.ClearTabTitle}"
Style="{StaticResource ExpanderSettingContainerStyle}"
CurrentValue="{x:Bind State.Profile.TabTitle, Mode=OneWay}"
HasSettingValue="{x:Bind State.Profile.HasTabTitle, Mode=OneWay}"
SettingOverrideSource="{x:Bind State.Profile.TabTitleOverrideSource, Mode=OneWay}">
<TextBox Style="{StaticResource TextBoxSettingStyle}"
Expand Down Expand Up @@ -305,7 +315,7 @@
ClearSettingValue="{x:Bind State.Profile.ClearScrollState}"
HasSettingValue="{x:Bind State.Profile.HasScrollState, Mode=OneWay}"
SettingOverrideSource="{x:Bind State.Profile.ScrollStateOverrideSource, Mode=OneWay}"
Style="{StaticResource AlternativeSettingContainerStyle}">
Style="{StaticResource ExpanderSettingContainerStyle}">
<muxc:RadioButtons AutomationProperties.AccessibilityView="Content"
ItemTemplate="{StaticResource EnumRadioButtonTemplate}"
ItemsSource="{x:Bind ScrollStateList, Mode=OneWay}"
Expand Down Expand Up @@ -411,7 +421,7 @@
ClearSettingValue="{x:Bind State.Profile.ClearAntialiasingMode}"
HasSettingValue="{x:Bind State.Profile.HasAntialiasingMode, Mode=OneWay}"
SettingOverrideSource="{x:Bind State.Profile.AntialiasingModeOverrideSource, Mode=OneWay}"
Style="{StaticResource AlternativeSettingContainerStyle}">
Style="{StaticResource ExpanderSettingContainerStyle}">
<muxc:RadioButtons AutomationProperties.AccessibilityView="Content"
ItemTemplate="{StaticResource EnumRadioButtonTemplate}"
ItemsSource="{x:Bind AntiAliasingModeList, Mode=OneWay}"
Expand Down Expand Up @@ -452,7 +462,7 @@
ClearSettingValue="{x:Bind State.Profile.ClearCloseOnExit}"
HasSettingValue="{x:Bind State.Profile.HasCloseOnExit, Mode=OneWay}"
SettingOverrideSource="{x:Bind State.Profile.CloseOnExitOverrideSource, Mode=OneWay}"
Style="{StaticResource AlternativeSettingContainerStyle}">
Style="{StaticResource ExpanderSettingContainerStyle}">
<muxc:RadioButtons AutomationProperties.AccessibilityView="Content"
ItemTemplate="{StaticResource EnumRadioButtonTemplate}"
ItemsSource="{x:Bind CloseOnExitModeList, Mode=OneWay}"
Expand All @@ -464,7 +474,7 @@
ClearSettingValue="{x:Bind State.Profile.ClearBellStyle}"
HasSettingValue="{x:Bind State.Profile.HasBellStyle, Mode=OneWay}"
SettingOverrideSource="{x:Bind State.Profile.BellStyleOverrideSource, Mode=OneWay}"
Style="{StaticResource AlternativeSettingContainerStyle}">
Style="{StaticResource ExpanderSettingContainerStyle}">
<StackPanel>
<CheckBox x:Uid="Profile_BellStyleAudible"
IsChecked="{x:Bind IsBellStyleFlagSet(1), BindBack=SetBellStyleAudible, Mode=TwoWay}" />
Expand Down
27 changes: 10 additions & 17 deletions src/cascadia/TerminalSettingsEditor/SettingContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
{
DependencyProperty SettingContainer::_HeaderProperty{ nullptr };
DependencyProperty SettingContainer::_HelpTextProperty{ nullptr };
DependencyProperty SettingContainer::_CurrentValueProperty{ nullptr };
DependencyProperty SettingContainer::_HasSettingValueProperty{ nullptr };
DependencyProperty SettingContainer::_SettingOverrideSourceProperty{ nullptr };

Expand Down Expand Up @@ -43,6 +44,15 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
xaml_typename<Editor::SettingContainer>(),
PropertyMetadata{ box_value(L"") });
}
if (!_CurrentValueProperty)
{
_CurrentValueProperty =
DependencyProperty::Register(
L"CurrentValue",
xaml_typename<hstring>(),
xaml_typename<Editor::SettingContainer>(),
PropertyMetadata{ box_value(L"") });
}
if (!_HasSettingValueProperty)
{
_HasSettingValueProperty =
Expand Down Expand Up @@ -72,23 +82,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation

void SettingContainer::OnApplyTemplate()
{
if (const auto& child{ GetTemplateChild(L"ExpanderButton") })
{
if (const auto& toggleButton{ child.try_as<Controls::Primitives::ToggleButton>() })
{
toggleButton.Click([=](auto&&, auto&&) {
if (const auto& expanderChild{ GetTemplateChild(L"MainContentContainer") })
{
if (const auto& expander{ expanderChild.try_as<Controls::Border>() })
{
const auto newVisibility = expander.Visibility() == Visibility::Visible ? Visibility::Collapsed : Visibility::Visible;
expander.Visibility(newVisibility);
}
}
});
}
}

if (const auto& child{ GetTemplateChild(L"ResetButton") })
{
if (const auto& button{ child.try_as<Controls::Button>() })
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsEditor/SettingContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation

DEPENDENCY_PROPERTY(Windows::Foundation::IInspectable, Header);
DEPENDENCY_PROPERTY(hstring, HelpText);
DEPENDENCY_PROPERTY(hstring, CurrentValue);
DEPENDENCY_PROPERTY(bool, HasSettingValue);
DEPENDENCY_PROPERTY(IInspectable, SettingOverrideSource);
TYPED_EVENT(ClearSettingValue, Editor::SettingContainer, Windows::Foundation::IInspectable);
Expand Down
3 changes: 3 additions & 0 deletions src/cascadia/TerminalSettingsEditor/SettingContainer.idl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ namespace Microsoft.Terminal.Settings.Editor
String HelpText;
static Windows.UI.Xaml.DependencyProperty HelpTextProperty { get; };

String CurrentValue;
static Windows.UI.Xaml.DependencyProperty CurrentValueProperty { get; };

Boolean HasSettingValue;
static Windows.UI.Xaml.DependencyProperty HasSettingValueProperty { get; };

Expand Down
Loading

1 comment on commit 13bbcbf

@github-actions
Copy link

@github-actions github-actions bot commented on 13bbcbf Nov 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@check-spelling-bot Report

Unrecognized words, please review:

  • ayy
Previously acknowledged words that are now absent carlos dpg sid SPACEBAR Unregister Urxvt vcvarsall xIcon yIcon zamora
To accept these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands

... in a clone of the git@github.com:microsoft/terminal.git repository
on the dev/pabhoj/SUI_11 branch:

update_files() {
perl -e '
my @expect_files=qw('".github/actions/spelling/expect/alphabet.txt
.github/actions/spelling/expect/expect.txt
.github/actions/spelling/expect/web.txt"');
@ARGV=@expect_files;
my @stale=qw('"$patch_remove"');
my $re=join "|", @stale;
my $suffix=".".time();
my $previous="";
sub maybe_unlink { unlink($_[0]) if $_[0]; }
while (<>) {
if ($ARGV ne $old_argv) { maybe_unlink($previous); $previous="$ARGV$suffix"; rename($ARGV, $previous); open(ARGV_OUT, ">$ARGV"); select(ARGV_OUT); $old_argv = $ARGV; }
next if /^(?:$re)(?:(?:\r|\n)*$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spelling/expect/13bbcbf50f9476f22fd78a4e7f803e4de9d30f13.txt";
use File::Path qw(make_path);
use File::Basename qw(dirname);
make_path (dirname($new_expect_file));
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"$patch_add"');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a)."-".$a cmp lc($b)."-".$b} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;
system("git", "add", $new_expect_file);
'
}

comment_json=$(mktemp)
curl -L -s -S \
  --header "Content-Type: application/json" \
  "https://api.github.com/repos/microsoft/terminal/comments/59861310" > "$comment_json"
comment_body=$(mktemp)
jq -r .body < "$comment_json" > $comment_body
rm $comment_json

patch_remove=$(perl -ne 'next unless s{^</summary>(.*)</details>$}{$1}; print' < "$comment_body")
  

patch_add=$(perl -e '$/=undef;
$_=<>;
s{<details>.*}{}s;
s{^#.*}{};
s{\n##.*}{};
s{(?:^|\n)\s*\*}{}g;
s{\s+}{ }g;
print' < "$comment_body")
  
update_files
rm $comment_body
git add -u
✏️ Contributor please read this

By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.

⚠️ The command is written for posix shells. You can copy the contents of each perl command excluding the outer ' marks and dropping any '"/"' quotation mark pairs into a file and then run perl file.pl from the root of the repository to run the code. Alternatively, you can manually insert the items...

If the listed items are:

  • ... misspelled, then please correct them instead of using the command.
  • ... names, please add them to .github/actions/spelling/allow/names.txt.
  • ... APIs, you can add them to a file in .github/actions/spelling/allow/.
  • ... just things you're using, please add them to an appropriate file in .github/actions/spelling/expect/.
  • ... tokens you only need in one place and shouldn't generally be used, you can add an item in an appropriate file in .github/actions/spelling/patterns/.

See the README.md in each directory for more information.

🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉

🗜️ If you see a bunch of garbage

If it relates to a ...

well-formed pattern

See if there's a pattern that would match it.

If not, try writing one and adding it to a patterns/{file}.txt.

Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

Note that patterns can't match multiline strings.

binary-ish string

Please add a file path to the excludes.txt file instead of just accepting the garbage.

File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

Please sign in to comment.