Microsoft-ui-xaml: Refactor MajorSize and other helpers to make them easier to read and understand

Created on 9 May 2019  路  4Comments  路  Source: microsoft/microsoft-ui-xaml

Describe the bug
See feedback in PR https://github.com/microsoft/microsoft-ui-xaml/pull/667
refactor the orientation based helper methods to make them easier to understand.

area-DevInternal area-ItemsRepeater help wanted team-Controls

All 4 comments

There are two/three ways we could improve the helpers:

  • Rename them to GetMajorSize or GetPointerToMajorSize
  • Provide a static SetMajorSize function that takes a float and a Size/Rect pointer
  • Do both

What would be the best way to solve this @ranjeshj @StephenLPeters @jevansaks (because you were one of the people confronted with this during review) ?

@jevansaks had a pretty good solution in the PR comments I think which we could run with.

float& MajorSize(winrt::Rect &rect)
{
    return isHorizontal ? rect.Width : rect.Height;
}

// use site:
MajorSize(bounds) = lineSize;

Seems like a good idea. I will create a PR for this soon if that's fine with you.

Sounds good. Thanks!

Was this page helpful?
0 / 5 - 0 ratings