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

Addition of MaxOpenBlades property on BladeView control #1049

Merged
merged 22 commits into from
Jun 27, 2017

Conversation

Depechie
Copy link
Contributor

Cfr #627 for the discussion and a demo movie posted to YouTube.

This is my vision of how we can keep screen real estate to a minimal when using blades.
The first original Azure portal had a similar feature ( although no longer present ).

In short, once we reached MaxOpenBlades count threshold of open blades with a title bar, we collapse all blades but the last one each time we add a new blade.
The sample page has been updated.

@deltakosh deltakosh added this to the v1.5 milestone Mar 24, 2017
@deltakosh deltakosh requested a review from skendrot April 4, 2017 16:49
@skendrot
Copy link
Contributor

skendrot commented Apr 4, 2017

Things I'd like to see in the PR:

  • Remove the BladeItemMode property (unless someone can give a concrete use case for needing the property)
  • Control the visual state of the BladeItem via a VisualState instead of BladeItemMode property
  • Change the name of MaxOpenBlades. This name says "You cannot have more than this number of blades". How about AutoCollapseCountThreshold. The default value for the property would be int.MaxValue
  • Allow the BladeItem to be collapsed and expanded regardless of the threshold value

@Depechie
Copy link
Contributor Author

Talked with @ScottIsAFool on possibility to add VisualStates in favour of the BladeItemMode, but due to the fact that we are working with a Templated control, I can't change a property of the Parent from within the Child. So we need to stick with the coded version.

Property name is changed to AutoCollapseCountThreshold and default value is now Int.MaxValue.
Now the enlarge button is always visible ( to shrink / enlarge the blade ).
When in small mode the content of the blade is hidden, will reshow when enlarged.
Sample page changed to show the AutoCollapseCountThreshold being set to 4 for the sample.

@skendrot
Copy link
Contributor

@Depechie Why are you saying it cannot be done? If the threshold is reached, call Collapse() on the items, in the Collapse method it fires an event that it has collapsed and sets a visual state. The BladeItem would also have an Expand method and an Expanded event. Or it could work like the Expander control and have an IsExpanded property. It could even inherit from Expander

@Depechie
Copy link
Contributor Author

Depechie commented May 19, 2017

@skendrot I tried that... if I introduced a visual state in the style for the BladeItem, I was not able to adjust it's own width. If you look at the expander, it's changing a property of a child element. That is indeed possible...

Could be I'm missing something, so be my guest and maybe you can retry it, just fork my repo?

Do note looked at it with @ScottIsAFool so guessing we both miss something you are seeing :D

@nmetulev
Copy link
Contributor

ping, do you guys think we can have this for 1.5?

@Depechie
Copy link
Contributor Author

Depechie commented May 29, 2017

@nmetulev for me there aren't any open issues with it anymore... not sure what the standpoint is from the core team?
Anyhow - if you accept the PR other people can still perform additions on it if needed. Or does a PR mean each final say has to be done by the PR submitter?

Copy link
Contributor

@ScottIsAFool ScottIsAFool left a comment

Choose a reason for hiding this comment

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

Minor code style adjustments, as long as they get done, consider this approved.


_enlargeButton.Click -= EnlargeButton_Click;
_enlargeButton.Click += EnlargeButton_Click;

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

private void OnSizeChanged(object sender, SizeChangedEventArgs sizeChangedEventArgs)
{
if(BladeItemMode == BladeItemMode.Normal)
_normalModeWidth = Width;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should have curly braces around if statement content.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

var openBlades = ActiveBlades.Where(item => item.TitleBarVisibility == Visibility.Visible).ToList();
if (openBlades?.Count > AutoCollapseCountThreshold)
{
for (int i = 0; i < openBlades.Count - 1; i++)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should have curly braces around for statement content

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -116,6 +127,9 @@ private void CycleBlades()

if (visibility == Visibility.Visible)
{
if (Items == null)
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Curly braces please.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


var lastBlade = ActiveBlades.LastOrDefault();
if (lastBlade != null && lastBlade.TitleBarVisibility == Visibility.Visible)
lastBlade.BladeItemMode = BladeItemMode.Normal;
Copy link
Contributor

Choose a reason for hiding this comment

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

Curly braces please.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -47,11 +54,29 @@ protected override void OnApplyTemplate()

_closeButton.Click -= CloseButton_Click;
_closeButton.Click += CloseButton_Click;

if (_enlargeButton == null)
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Curly braces please.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


ContentPresenter content = bladeItem.GetTemplateChild("ContentPresenter") as ContentPresenter;
if (content == null)
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Curly braces please.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@skendrot
Copy link
Contributor

@Depechie We don't need to set the width when a blade item is collapsed. Create a Visual State for expanded and collapsed. When collapsed set the visibility of the ContentPresenter and the title bar to Collapsed. This will make the entire control the width you are expecting.
I also wouldn't expect collapsing when in full screen mode.
The button needs to change from collapse to expand depending on the visual state

@skendrot
Copy link
Contributor

What are other thoughts about making the BladeItem an Expander control?

@Depechie
Copy link
Contributor Author

@skendrot Changing it to an expander control is maybe not such a bad idea indeed
But this means throwing out current implementation I guess

About the Visual States, if you can show this can be done through my PR, I'm happy to learn :)

skendrot and others added 4 commits May 30, 2017 10:44
Add a visual state for expanded/collaped to the blade item
Control the blade item visual state when the mode changes
@Depechie
Copy link
Contributor Author

@nmetulev was this q directed to me?
If so... I did all the code for the idea I myself proposed - the idea is working as expected and after the code reviews all changes were made to adjust for the remarks.
Seems this was the way other PR's worked.
Now at the end after the work, only @skendrot is suggesting to refactor the control.

So does your question mean you guys now only want the control change in there when it is a real expander instead of the current rework?
If so, count me out, would have been nice to at least think upfront and don't let community people spend time to try to get a PR that has no value in the end.
Would still guess this PR can be added and put the refactor up for future release, but long story short, just drop the PR if an expander is needed.

@skendrot
Copy link
Contributor

@Depechie If changing to an expander is too difficult I can handle the changes

// For now we skip this feature when blade mode is set to fullscreen
if (AutoCollapseCountThreshold > 0 && BladeMode != BladeMode.Fullscreen && ActiveBlades.Any())
{
var openBlades = ActiveBlades.Where(item => item.TitleBarVisibility == Visibility.Visible).ToList();
Copy link
Contributor

@skendrot skendrot Jun 21, 2017

Choose a reason for hiding this comment

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

Should check the expand mode instead of the visibility of the title bar. This could be set by the user

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My understanding was that the TitleBarVisibility property was used to pin blades to the screen.
I want to filter the pinned once out, they are not touched by the auto resize mechanism.
@skendrot Is there another property that tells me this? I don't seem to find it...

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right! Thanks for pointing that out

if (AutoCollapseCountThreshold > 0 && BladeMode != BladeMode.Fullscreen && ActiveBlades.Any())
{
var openBlades = ActiveBlades.Where(item => item.TitleBarVisibility == Visibility.Visible).ToList();
if (openBlades?.Count > AutoCollapseCountThreshold)
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to check for null, guaranteed to be a list

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

{
for (int i = 0; i < openBlades.Count - 1; i++)
{
openBlades[i].BladeItemMode = BladeItemMode.Small;
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this close ALL open blades? Or just the amount under the threshold count?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All open blades except the last one, IF the amount of blades drawn is over the threshold.

@@ -133,6 +151,12 @@ private void CycleBlades()

BladeClosed?.Invoke(this, blade);
ActiveBlades.Remove(blade);

var lastBlade = ActiveBlades.LastOrDefault();
if (lastBlade != null && lastBlade.TitleBarVisibility == Visibility.Visible)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't check the titlebar visibility. This can be set to collapsed by the user but still want the last blade to be expanded

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same remark as above, I don't want to auto size pinned blades.

@nmetulev
Copy link
Contributor

Apologies for randomizing you :(. My vote is to keep the changes you've done as it seems that your changes are very useful and needed. We should then open a new issue to discuss further updates/changes to the control before we start a new PR.

Looks like @skendrot has some minor requests that should be looked at before merging the control. Do you think you can take a look at those this week?

@Depechie
Copy link
Contributor Author

@nmetulev done the changes and commented on the other questions of @skendrot - but guessing that has to be reviewed again. Because could be my view is not the same as the UWP toolkit team.

@skendrot
Copy link
Contributor

Tested this out. If I set the AutoCollapse to 3 and open three blades they are all open. When I open the forth it collapses the first three and then leaves the last one open. If I add a fifth it collapses the fourth and leaves the fifth open.

I was expecting it to always leave the last three open. This is probably a misunderstanding on my part but I'm wondering if others will think the same.

Should it only leave the last one open? Or should it leave the amount open that you specify?

@Depechie
Copy link
Contributor Author

Depechie commented Jun 22, 2017

Yeah... every person could have a different view on this I guess!
Why I wanted this was to allow for some sort of action flow ( like the azure portal ), where a blade is open and doing something there will trigger a new blade to appear that needs the users attention.
This can continue, meaning the previous open blades are actually a distraction.
Thus to not clutter the screen and keep the user engaging with the blade that needs attention, I want all blades closed except the last one.
The threshold is there because of screen size differences and blade widths.

We could add an extra property to also accomplish the other need, to start collapsing blades After the threshold count AND keep in mind the new property called KeepOpenBlades for example to not close the x last ones where x equals that keep open property.
But still, would not do this in same PR for testing and evaluation reasons.

@skendrot
Copy link
Contributor

skendrot commented Jun 22, 2017

Yea, completely understand the usecase and I agree the open blades can be a distraction. Definitely no need to update this PR to handle a different use case.

I'm good with things as is. @nmetulev, what are your thoughts on the workflow or property name? Do they communicate the intended functionality properly?

@nmetulev
Copy link
Contributor

Reading your description again, it makes sense why you are doing it this way. But just from the property name, I had the same assumption as @skendrot, that it would only keep up to max open blades. How do you feel about changing the name to something else, maybe along the lines of "CollapseAllButLastThreshold"

@skendrot
Copy link
Contributor

The original property was named MaxOpenBlades. The current name is AutoCollapseCountThreshold

@nmetulev
Copy link
Contributor

Oh, that's much better, apologies. I'm good with that name :)

@nmetulev
Copy link
Contributor

We should make sure we add it to the documentation though before we merge it :)

@nmetulev
Copy link
Contributor

@Depechie, could you add the new property to the documentation before we merge?

@Depechie
Copy link
Contributor Author

@nmetulev ok will try to fit that in this week!

@nmetulev
Copy link
Contributor

Thanks @Depechie, let me know if you can make it by Wednesday, or if you need help. Code freeze for 1.5 is Wednesday EOD PST.

Depechie and others added 2 commits June 27, 2017 21:35
Added new AutoCollapseCountThreshold to documents
@Depechie
Copy link
Contributor Author

@nmetulev could some people double check for English spelling error, and is the wording ok? Updated the BladeView.md.

@@ -66,6 +66,12 @@ Here is an example of a BladeView where the `BladeMode` property is binded to a

```

## AutoCollapseCountThreshold

If you want to use the BladeView for handling a flow of actions, you can use the `AutoCollapseCountThreshold` property to tell it to start auto collapsing BladeItems after a certain threshold count has been reached. This will also help keeping a clean, uncluttered screen real estate.
Copy link
Contributor

Choose a reason for hiding this comment

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

Change

This will also help keeping a clean, uncluttered screen real estate.

To

This will also help keep a clean, uncluttered screen real estate.

(change keeping to keep)

English is hard

If you want to use the BladeView for handling a flow of actions, you can use the `AutoCollapseCountThreshold` property to tell it to start auto collapsing BladeItems after a certain threshold count has been reached. This will also help keeping a clean, uncluttered screen real estate.

Let's explain this with an example; if you put the `AutoCollapseCountThreshold` property to 3, the BladeView will start counting all BladeItems that are open in the BladeView and have their `TitleBarVisibility` property set to Visible. When the n+1 BladeItem, in our case the 4th one, is being added, the BladeView will auto collaps all n BladeItems except for the last one. All additional BladeItems that are added afterwards will trigger the same effect; collapse all BladeItems except for the last open one.
Copy link
Contributor

Choose a reason for hiding this comment

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

Change

Let's explain this with an example

To

For example


If you want to use the BladeView for handling a flow of actions, you can use the `AutoCollapseCountThreshold` property to tell it to start auto collapsing BladeItems after a certain threshold count has been reached. This will also help keeping a clean, uncluttered screen real estate.

Let's explain this with an example; if you put the `AutoCollapseCountThreshold` property to 3, the BladeView will start counting all BladeItems that are open in the BladeView and have their `TitleBarVisibility` property set to Visible. When the n+1 BladeItem, in our case the 4th one, is being added, the BladeView will auto collaps all n BladeItems except for the last one. All additional BladeItems that are added afterwards will trigger the same effect; collapse all BladeItems except for the last open one.
Copy link
Contributor

Choose a reason for hiding this comment

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

Change

if you put the AutoCollapseCountThreshold property to 3

To

if you set AutoCollapseCountThreshold to 3


If you want to use the BladeView for handling a flow of actions, you can use the `AutoCollapseCountThreshold` property to tell it to start auto collapsing BladeItems after a certain threshold count has been reached. This will also help keeping a clean, uncluttered screen real estate.

Let's explain this with an example; if you put the `AutoCollapseCountThreshold` property to 3, the BladeView will start counting all BladeItems that are open in the BladeView and have their `TitleBarVisibility` property set to Visible. When the n+1 BladeItem, in our case the 4th one, is being added, the BladeView will auto collaps all n BladeItems except for the last one. All additional BladeItems that are added afterwards will trigger the same effect; collapse all BladeItems except for the last open one.
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix spelling of collaps

the BladeView will auto collaps all

More spell checking
@skendrot skendrot merged commit b519192 into CommunityToolkit:dev Jun 27, 2017
skendrot added a commit to skendrot/UWPCommunityToolkit that referenced this pull request Jun 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants