-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Add some polish to nested commands in the command palette #7299
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,8 @@ the MIT License. See LICENSE in the project root for license information. --> | |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:Windows10version1903="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract, 8)" | ||
TabNavigation="Cycle" | ||
IsTabStop="True" | ||
TabNavigation="Cycle" | ||
IsTabStop="True" | ||
AllowFocusOnInteraction="True" | ||
PointerPressed="_rootPointerPressed" | ||
PreviewKeyDown="_previewKeyDownHandler" | ||
|
@@ -27,7 +27,9 @@ the MIT License. See LICENSE in the project root for license information. --> | |
<Windows10version1903:ThemeShadow x:Name="CommandPaletteShadow" /> | ||
|
||
<!-- This creates an instance of our CommandKeyChordVisibilityConverter we can reference below --> | ||
<local:CommandKeyChordVisibilityConverter x:Key="CommandKeyChordVisibilityConverter"/> | ||
<local:EmptyStringVisibilityConverter x:Key="CommandKeyChordVisibilityConverter"/> | ||
<local:EmptyStringVisibilityConverter x:Key="ParentCommandVisibilityConverter"/> | ||
<local:HasNestedCommandsVisibilityConverter x:Key="HasNestedCommandsVisibilityConverter"/> | ||
|
||
<ResourceDictionary.ThemeDictionaries> | ||
<ResourceDictionary x:Key="Dark"> | ||
|
@@ -170,12 +172,23 @@ the MIT License. See LICENSE in the project root for license information. --> | |
</TextBox> | ||
|
||
<TextBlock | ||
Padding="16" | ||
x:Name="_noMatchesText" | ||
FontStyle="Italic" | ||
Visibility="Collapsed" | ||
Grid.Row="1" | ||
Text="{x:Bind NoMatchesText, Mode=OneWay}"> | ||
Padding="16, 0, 16, 4" | ||
x:Name="_parentCommandText" | ||
FontStyle="Italic" | ||
Visibility="{x:Bind ParentCommandName, | ||
Mode=OneWay, | ||
Converter={StaticResource ParentCommandVisibilityConverter}}" | ||
Grid.Row="1" | ||
Text="{x:Bind ParentCommandName, Mode=OneWay}"> | ||
</TextBlock> | ||
|
||
<TextBlock | ||
Padding="16" | ||
x:Name="_noMatchesText" | ||
FontStyle="Italic" | ||
Visibility="Collapsed" | ||
Grid.Row="1" | ||
Text="{x:Bind NoMatchesText, Mode=OneWay}"> | ||
</TextBlock> | ||
|
||
<ListView | ||
|
@@ -236,6 +249,21 @@ the MIT License. See LICENSE in the project root for license information. --> | |
Text="{x:Bind KeyChordText, Mode=OneWay}" /> | ||
</Border> | ||
|
||
<!-- xE70E is ChevronUp. Rotated 90 degrees, it's _ChevronRight_ --> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HA, clever |
||
<FontIcon | ||
FontFamily="Segoe MDL2 Assets" | ||
Glyph="" | ||
HorizontalAlignment="Right" | ||
Visibility="{x:Bind HasNestedCommands, | ||
Mode=OneWay, | ||
Converter={StaticResource HasNestedCommandsVisibilityConverter}}" | ||
Grid.Column="2"> | ||
|
||
<FontIcon.RenderTransform> | ||
<RotateTransform CenterX="0.5" CenterY="0.5" Angle="90"/> | ||
</FontIcon.RenderTransform> | ||
</FontIcon> | ||
|
||
</Grid> | ||
</ListViewItem> | ||
</DataTemplate> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/cascadia/TerminalApp/HasNestedCommandsVisibilityConverter.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "pch.h" | ||
#include "HasNestedCommandsVisibilityConverter.h" | ||
#include "HasNestedCommandsVisibilityConverter.g.cpp" | ||
|
||
using namespace winrt::Windows; | ||
using namespace winrt::Windows::UI::Xaml; | ||
|
||
namespace winrt::TerminalApp::implementation | ||
{ | ||
// Method Description: | ||
// - Attempt to convert something into another type. For the | ||
// HasNestedCommandsVisibilityConverter, we're gonna check if `value` is a | ||
// string, and try and convert it into a Visibility value. If the input | ||
// param wasn't a string, or was the empty string, we'll return | ||
// Visibility::Collapsed. Otherwise, we'll return Visible. | ||
|
||
// Arguments: | ||
// - value: the input object to attempt to convert into a Visibility. | ||
// Return Value: | ||
// - Visible if the object was a string and wasn't the empty string. | ||
Foundation::IInspectable HasNestedCommandsVisibilityConverter::Convert(Foundation::IInspectable const& value, | ||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */, | ||
Foundation::IInspectable const& /* parameter */, | ||
hstring const& /* language */) | ||
{ | ||
const auto& hasNestedCommands = winrt::unbox_value_or<bool>(value, false); | ||
return winrt::box_value(hasNestedCommands ? Visibility::Visible : Visibility::Collapsed); | ||
} | ||
|
||
// unused for one-way bindings | ||
Foundation::IInspectable HasNestedCommandsVisibilityConverter::ConvertBack(Foundation::IInspectable const& /* value */, | ||
Windows::UI::Xaml::Interop::TypeName const& /* targetType */, | ||
Foundation::IInspectable const& /* parameter */, | ||
hstring const& /* language */) | ||
{ | ||
throw hresult_not_implemented(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/cascadia/TerminalApp/HasNestedCommandsVisibilityConverter.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
|
||
#include "HasNestedCommandsVisibilityConverter.g.h" | ||
#include "..\inc\cppwinrt_utils.h" | ||
|
||
namespace winrt::TerminalApp::implementation | ||
{ | ||
struct HasNestedCommandsVisibilityConverter : HasNestedCommandsVisibilityConverterT<HasNestedCommandsVisibilityConverter> | ||
{ | ||
HasNestedCommandsVisibilityConverter() = 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::TerminalApp::factory_implementation | ||
{ | ||
BASIC_FACTORY(HasNestedCommandsVisibilityConverter); | ||
} |
19 changes: 19 additions & 0 deletions
19
src/cascadia/TerminalApp/HasNestedCommandsVisibilityConverter.idl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
namespace TerminalApp | ||
{ | ||
// See https://docs.microsoft.com/en-us/windows/uwp/data-binding/data-binding-quickstart | ||
|
||
// We use the default attribute to declare IValueConverter as the default | ||
// interface. In the listing, HasNestedCommandsVisibilityConverter has only a | ||
// constructor, and no methods, so no default interface is generated for it. | ||
// The default attribute is optimal if you won't be adding instance members | ||
// to HasNestedCommandsVisibilityConverter, because no QueryInterface will be | ||
// required to call the IValueConverter methods | ||
runtimeclass HasNestedCommandsVisibilityConverter : [default] Windows.UI.Xaml.Data.IValueConverter | ||
{ | ||
HasNestedCommandsVisibilityConverter(); | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
future: we may want to display the icon if it has one, too.