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

Add percentage sign to opacity slider values #10369

Merged
6 commits merged into from
Jun 9, 2021

Conversation

marcelwgn
Copy link
Contributor

@marcelwgn marcelwgn commented Jun 8, 2021

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.

@ghost ghost added Area-Settings UI Anything specific to the SUI Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. labels Jun 8, 2021
Copy link
Member

@carlos-zamora carlos-zamora left a 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.

Comment on lines 9 to 30
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);
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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 :)

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jun 9, 2021
Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com>
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jun 9, 2021
Copy link
Member

@DHowett DHowett left a 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. 😄

@DHowett DHowett added AutoMerge Marked for automatic merge by the bot when requirements are met zPreview-Service-Queued-1.13 A floating label that tracks the current Preview version for servicing purposes. labels Jun 9, 2021
@ghost
Copy link

ghost commented Jun 9, 2021

Hello @DHowett!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

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 (@msftbot) and give me an instruction to get started! Learn more here.

Copy link
Member

@carlos-zamora carlos-zamora left a 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.

@ghost ghost removed the AutoMerge Marked for automatic merge by the bot when requirements are met label Jun 9, 2021
@marcelwgn
Copy link
Contributor Author

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)?

@carlos-zamora carlos-zamora added the AutoMerge Marked for automatic merge by the bot when requirements are met label Jun 9, 2021
@ghost ghost merged commit becc254 into microsoft:main Jun 9, 2021
@DHowett DHowett removed the zPreview-Service-Queued-1.13 A floating label that tracks the current Preview version for servicing purposes. label Jul 7, 2021
DHowett pushed a commit that referenced this pull request Jul 7, 2021
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.

* [x] Closes #10289

(cherry picked from commit becc254)
@ghost
Copy link

ghost commented Jul 14, 2021

🎉Windows Terminal v1.9.1942.0 has been released which incorporates this pull request.:tada:

Handy links:

@ghost
Copy link

ghost commented Jul 14, 2021

🎉Windows Terminal Preview v1.10.1933.0 has been released which incorporates this pull request.:tada:

Handy links:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings UI Anything specific to the SUI AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[settings] Acrylic opacity option could/should include percent sign.
3 participants