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

Fixes to a few NumberBox issues #1894

Merged
merged 4 commits into from
Feb 3, 2020
Merged

Fixes to a few NumberBox issues #1894

merged 4 commits into from
Feb 3, 2020

Conversation

teaP
Copy link
Contributor

@teaP teaP commented Jan 27, 2020

I originally assumed that creating a new DecimalFormatter would, by default, conform to the user's selected language/region. Confoundingly, it does not. I lifted the related code in Calculator to create a DecimalFormatter with the right defaults, which fixes #1798.

I also moved the header/description content from being handled by EditBox to being in NumberBox directly. This allows me to size the up/down buttons to be the same size as the EditBox, which fixes #1846 and fixes #1839.

With description text at 125% DPI:
image

@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Jan 27, 2020
@ranjeshj ranjeshj added needs-cherrypicktorelease PR tagged for cherry-pick to the current release branch (but not yet picked) and removed needs-triage Issue needs to be triaged by the area owners labels Jan 28, 2020
@ranjeshj ranjeshj added area-NumberBox NumberBox Control team-Controls Issue for the Controls team labels Jan 28, 2020
// This was largely copied from Calculator's GetRegionalSettingsAwareDecimalFormatter()
winrt::DecimalFormatter NumberBox::GetRegionalSettingsAwareDecimalFormatter()
{
std::vector<winrt::hstring> languageList;
Copy link
Contributor

Choose a reason for hiding this comment

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

std::vectorwinrt::hstring languageList; [](start = 4, length = 41)

Why is this a vector? seems like we only ever add one item max

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's just what the constructor for NumberFormatter wants.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it would be cleaner to create the vector only once you have a language name? You might be able to do it with initializer syntax in the ternary operator below, I'm not sure.


In reply to: 372026234 [](ancestors = 372026234)

Copy link
Member

Choose a reason for hiding this comment

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

Maybe initialize the size to 0? I'm not sure if that avoids an allocation. Maybe just look at / debug through the STL implementation? https://github.com/microsoft/STL/blob/master/stl/inc/vector#L469

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 don't think I can do it in one line so I switched it around a bit.

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@yaira2
Copy link
Contributor

yaira2 commented Jan 29, 2020

image

If you look closely at the up arrow then you can see that there are still scaling issues there. It would be great if this could be fixed before the pull request is merged.

@teaP
Copy link
Contributor Author

teaP commented Jan 29, 2020

If you look closely at the up arrow then you can see that there are still scaling issues there. It would be great if this could be fixed before the pull request is merged.

Yeah, I know, but unfortunately it's a CornerRadius issue. Having any value >0 in CornerRadius scales the border differently than if it's 0.

image

I followed up offline with the team that owns rendering, but for this PR there's nothing more I can do.


if (winrt::Language::IsWellFormed(currentLocale))
{
languageList.push_back(winrt::hstring(currentLocale));
Copy link
Contributor

Choose a reason for hiding this comment

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

you could use emplace_back(currentLocale);

if (!formatter)
{
formatter = winrt::DecimalFormatter();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd probably make this a lambda to avoid the scratch variable.

Copy link
Contributor

@StephenLPeters StephenLPeters left a comment

Choose a reason for hiding this comment

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

:shipit:

@teaP teaP merged commit 1c09f51 into master Feb 3, 2020
@teaP teaP deleted the user/teaP/NumberBoxFix branch February 3, 2020 20:47
ranjeshj pushed a commit that referenced this pull request Feb 4, 2020
* Fixes to a few NumberBox issues.

* PR update

* PR feedback and fixed downlevel missing resource.
ranjeshj pushed a commit that referenced this pull request Feb 9, 2020
* Fixes to a few NumberBox issues.

* PR update

* PR feedback and fixed downlevel missing resource.
@ranjeshj ranjeshj removed the needs-cherrypicktorelease PR tagged for cherry-pick to the current release branch (but not yet picked) label Feb 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NumberBox NumberBox Control team-Controls Issue for the Controls team
Projects
None yet
6 participants