-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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 percentage sign to opacity slider values #10369
Conversation
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.
Really just blocking over the PercentageSignConverter::ConvertBack
. The rest are just nits.
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation | ||
{ | ||
struct PercentageSignConverter : PercentageSignConverterT<PercentageSignConverter> | ||
{ | ||
PercentageSignConverter() = 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(PercentageSignConverter); | ||
} |
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.
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation | |
{ | |
struct PercentageSignConverter : PercentageSignConverterT<PercentageSignConverter> | |
{ | |
PercentageSignConverter() = 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(PercentageSignConverter); | |
} | |
DECLARE_CONVERTER(winrt::Microsoft::Terminal::Settings::Editor, PercentageSignConverter); |
nit: here's a nice macro we have to make this easier :)
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.
nit: you could also throw this declaration into PercentageConverter.h
(and the implementation into the corresponding cpp file). That way we have less files going around.
See https://github.com/microsoft/terminal/blob/main/src/cascadia/TerminalSettingsEditor/StringIsNotDesktopConverter.h, if interested. We did the same thing there.
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.
I'm not too much of a fan of putting that in the PercentageConverter.h file since it's not really related to this. How about (a future) refactor, we have a DeclareConverter.h
where we can put those statements? That way, we probably could get rid of a few headers files more easily.
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.
My intent is to move us all away from object-based converters in the future, so we can put a pin in this.
src/cascadia/TerminalSettingsEditor/PercentageSignConverter.cpp
Outdated
Show resolved
Hide resolved
src/cascadia/TerminalSettingsEditor/Microsoft.Terminal.Settings.Editor.vcxproj
Outdated
Show resolved
Hide resolved
Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com>
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.
Thanks for this! It's excellent.
I wanted to make a comment about using bound function converters instead of class-based converters, but I'll hold off for now. I don't know if functions work with Binding
, and I do not understand WHY we are using Binding
instead of x:Bind
here, so I am not going to force you to rearchitect our code.
Thanks so much. 😄
Hello @DHowett! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
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.
Thanks!
@DHowett FYI you could also throw this in Stable if you wanted to.
You are too kind @DHowett and @carlos-zamora ! Regarding the bound functional converters, if there are plans for this, I can definitely try and help with refactoring this! Is there already some kind of tracking for this (e.g. an issue)? |
🎉 Handy links: |
🎉 Handy links: |
This PR adds a new PercentageSignConverter that appends the percentage sign to a number. The new converter is being used by the Acrylic opacity slider label and the Background image opacity slider label.