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

Pager: Add Auto Display Mode functionality #3239

Merged
merged 57 commits into from
Sep 4, 2020
Merged

Pager: Add Auto Display Mode functionality #3239

merged 57 commits into from
Sep 4, 2020

Conversation

gvazquez8
Copy link

@gvazquez8 gvazquez8 commented Sep 3, 2020

Previously, Auto Display mode only set the pager control to the ComboBox Display mode.
This PR allows the Auto Display mode to decide between the ComboBox display mode and NumberBox Display mode based on the NumberOfPages.

Motivation and Context

Proposal: #60
Spec: link

How Has This Been Tested?

Manually tested as well as Interaction Tests

Screenshots (if appropriate):

AutoDisplayMode

Gabriel Vazquez and others added 30 commits July 6, 2020 17:10
…mily on pager buttons Segoe MDL2 static resource
Removing c++ project
Removing c++ project
Removing C++ project
This reverts commit 9665cea.
This reverts commit fadef53.
@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Sep 3, 2020
@gvazquez8
Copy link
Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -812,6 +823,19 @@ void VerifyDisplayMode(DisplayModes mode)
switch (mode)
{
case DisplayModes.Auto:
if (elements.GetNumberOfPagesTextBlock().GetText() == "100")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it might be better to make this a bit more flexible, e.g. try to convert this to int and check if its higher than lets say 50.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or ideally use the magic const 11 we use in the actual control.

@@ -113,10 +114,12 @@ private void OnPagerDisplayModeChanged()
{
switch (this.PagerDisplayMode)
{
case PagerDisplayModes.Auto:
VisualStateManager.GoToState(this, NumberOfPages < 11 ? ComboBoxVisibleVisualState : NumberBoxVisibleVisualState, false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

@MarissaMatt The proposal only says something about less than 11 and larger than 11, what about 11 itsself? Is case 11 resulting in NumberBox correct here? I think the spec might need some clarification for this.

Copy link
Author

Choose a reason for hiding this comment

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

@chingucoding can you point me to where it talks about the "less than 11 and larger than 11" on the proposal? I can't seem to find any reference to it there. I know the spec mentions it, but I'm interested to see what the proposal mentions.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure, it is the first paragraph in this section: https://github.com/microsoft/microsoft-ui-xaml-specs/blob/user/savoyschuler/pagercontrol/active/PagerControl/PagerControl.md#creating-a-pager-control

It states:

"[...] NumberOfPages property is less than 11 and will show the number box mode if it is greater than 11."

Copy link
Contributor

Choose a reason for hiding this comment

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

I updated the spec with that requirement but not the proposal so I will make sure they are both matching. The requirement should be if it's 10 pages or less then combo box will be chosen and if it's 10 or more then number box will be chosen.

Copy link
Author

Choose a reason for hiding this comment

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

I'm still a little confused..

So should it be:
if NumberOfPages <= 10 then use ComboBox else use NumberBox
or
if NumberOfPages < 10 then use ComboBox else use NumberBox

Copy link
Contributor

Choose a reason for hiding this comment

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

It should be if NumberOfPages < 10 then use ComboBox else use NumberBox

Copy link
Author

Choose a reason for hiding this comment

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

Great thanks! I'll update the prototype

@StephenLPeters StephenLPeters added area-Pager team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Sep 3, 2020
@gvazquez8
Copy link
Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -33,10 +33,11 @@ public enum ButtonVisibilityMode { Auto, AlwaysVisible, HiddenOnEdge, None, }
private ItemsRepeater PagerNumberPanel;
private Rectangle NumberPanelCurrentPageIdentifier;

private static int AutoDisplayModeNumberOfPagesThreshold = 10; // This integer determines when to switch between NumberBoxDisplayMode and ComboBoxDisplayMode
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just putting this out as a thought: Should we make this customizable? Of course not in this PR, but maybe this is something we could think about for the future.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this adds very much, if you want to customize this you could just change your display mode from combo box to numberbox at your chosen threshold, which doesn't seem like an issue.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fair point, though with that argument you could also argue why we need this in the first place given that devs can implement it themselves. But yeah, it probably doesn't add much to the API.

Copy link
Contributor

Choose a reason for hiding this comment

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

But this gets us the default behavior that our designers think is best. If another app's designer wants a different behavior they can change that but if they want to default to our design this does that for them


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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh yes, that's a very good point. That ensures that app's all use the recommended behavior if they aren't actively trying to work around that. This shouldn't be customizable then.

@@ -14,5 +14,7 @@ public sealed partial class PrototypePager : Control
public ComboBox ComboBoxDisplayTestHook;
public ItemsRepeater NumberPanelDisplayTestHook;
public Rectangle NumberPanelCurrentPageIdentifierTestHook;

public int AutoDisplayModeNumberOfPagesThresholdTestHook;
Copy link
Contributor

Choose a reason for hiding this comment

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

AutoDisplayModeNumberOfPagesThresholdTestHook [](start = 19, length = 45)

It looks like your test app doesn't use this expect to show the value. In a production environment these are not free and I think we should avoid them if they aren't useful. For the production version of this I would just hard code the value in the test app.

Copy link
Author

Choose a reason for hiding this comment

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

I've removed it!

@@ -529,6 +529,17 @@ public void ChangingDisplayModeTest()

SetNumberPanelDisplayMode();
VerifyNumberPanelDisplayMode();

ChangeNumberOfPages();
VerifyNumberOfPages("100");
Copy link
Contributor

Choose a reason for hiding this comment

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

100 [](start = 37, length = 3)

I would also verify the boundaries, since the display mode changes at 10 we should be testing 9 and 10 as well.

Copy link
Author

Choose a reason for hiding this comment

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

Done

@gvazquez8
Copy link
Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@gvazquez8 gvazquez8 merged commit a154532 into microsoft:master Sep 4, 2020
@gvazquez8 gvazquez8 deleted the AutoDisplayModeDev branch September 4, 2020 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Pager team-Controls Issue for the Controls team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants