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

Align TabView visuals with Edge #2201

Merged
merged 16 commits into from
May 19, 2020

Conversation

marcelwgn
Copy link
Collaborator

Description

This PR aligns the visuals of the TabView control with chromium Edge by adding the corner radii on the bottom of the TabViewItems

Motivation and Context

Align visuals with Edge

How Has This Been Tested?

Tested manually.

Screenshots (if appropriate):

tabview-fluent-2

@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Mar 31, 2020
@stmoy stmoy requested a review from teaP March 31, 2020 21:13
@mdtauk
Copy link
Contributor

mdtauk commented Mar 31, 2020

Glad you were able to implement this. I think there may need to be a provision to remove those inset corners when the CornerRadius value is set to something other than the default. If I read the code right, you have used path geometry to do them.

@marcelwgn
Copy link
Collaborator Author

Yes I use path, however if we change the OverlayCornerRadius themeresource, this changes all corner radii of the TabViewItems, that is setting it to 10 sets it to 10 for all 4 corners, and setting it to 0 removes them. That is because of the Stretch="Uniform" .

@mdtauk
Copy link
Contributor

mdtauk commented Mar 31, 2020

Yes I use path, however if we change the OverlayCornerRadius themeresource, this changes all corner radii of the TabViewItems, that is setting it to 10 sets it to 10 for all 4 corners, and setting it to 0 removes them. That is because of the Stretch="Uniform" .

And does that affect the paths used for the bottom inset corners?

@marcelwgn
Copy link
Collaborator Author

Yes, it does:

image

@mdtauk
Copy link
Contributor

mdtauk commented Mar 31, 2020

Yes, it does:

image

One more question. Does this work with the TabBar Background using a HostBackdrop Acrylic of say 60% and the Current TabView colour using the same Acrylic, but at 80-90%?

I am guessing the answer is yes, but I gotta ask lol

@marcelwgn
Copy link
Collaborator Author

One more question. Does this work with the TabBar Background using a HostBackdrop Acrylic of say 60% and the Current TabView colour using the same Acrylic, but at 80-90%?
I am guessing the answer is yes, but I gotta ask lol

Interesting question! That also works:
tabview-fluent-acrylic-backdrop

@mdtauk
Copy link
Contributor

mdtauk commented Mar 31, 2020

One more question. Does this work with the TabBar Background using a HostBackdrop Acrylic of say 60% and the Current TabView colour using the same Acrylic, but at 80-90%?
I am guessing the answer is yes, but I gotta ask lol

Interesting question! That also works:
tabview-fluent-acrylic-backdrop

BRILLIANT! Just wanted to make sure there would be no problem with overlaps or gaps between elements which can be disguised fine with opaque colours, but not with transparencies!

dev/TabView/TabView.xaml Outdated Show resolved Hide resolved
@@ -182,8 +182,12 @@ unsealed runtimeclass TabViewItemTemplateSettings : Windows.UI.Xaml.DependencyOb
TabViewItemTemplateSettings();

Windows.UI.Xaml.Controls.IconElement IconElement;
Windows.UI.Xaml.Thickness LeftInsetRadiusMargin;
Copy link
Contributor

Choose a reason for hiding this comment

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

@stmoy need API review for these ?

@@ -84,6 +92,15 @@ void TabViewItem::OnApplyTemplate()

void TabViewItem::OnIsSelectedPropertyChanged(const winrt::DependencyObject& sender, const winrt::DependencyProperty& args)
{
if (IsSelected())
{
SetValue(winrt::Canvas::ZIndexProperty(),box_value(20));
Copy link
Contributor

Choose a reason for hiding this comment

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

can this be done in the visual state ?

Copy link
Contributor

Choose a reason for hiding this comment

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

If Tab Placement for the bottom or sides is added, there will need to be new visual states added. Would that cause any issues?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

can this be done in the visual state ?

If we want the inset corners to be able to register hits, so that clicking on them does not switch the selection to the item they are on top, unfortunately not.

If Tab Placement for the bottom or sides is added, there will need to be new visual states added. Would that cause any issues?

Since we are talking about ZIndex here, this won't be problematic with the bottoms or side. The inset corners may become problematic, but that is something we need to deal with later.

Copy link
Contributor

Choose a reason for hiding this comment

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

can this be done in the visual state ?

If we want the inset corners to be able to register hits, so that clicking on them does not switch the selection to the item they are on top, unfortunately not.

I don't understand this, I agree the property needs to be set to achieve this but it should be settable from the visual state shouldn't it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Setting the ZIndex does not work in the visual state as we can't set the ZIndex of the TabViewItem itsself. Setting it on the LayoutRoot does not work, as setting ZIndex of the layoutroot only "lifts" the LayoutRoot relative to other childs with same parent. Since the TabViewItem needs to be lifted relative to the other TabViewItems, we need to set that items ZIndex.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I didn't see this a while ago.. I thought adding this to the selected state in the TabViewItem's VSM would set the ZIndex on the TVI itself:

<Setter Property="Canvas.ZIndex" Value="20"/>

I think ommiting a target makes the property get set on the TVI itself

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Trying to define it using Setter.Property results in the following compile error:

1>D:\Projects\microsoft-ui-xaml\BuildOutput\Debug\x64\Microsoft.UI.Xaml\rs2_generic.xaml(556,54): XamlCompiler error WMC0610: The XAML Binary Format (XBF) generator reported syntax error '0x09ff'

Any ideas @StephenLPeters what could cause this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect the syntax is a bit different but I'm not sure what it is precisely, I think its fine to leave as is.

dev/TabView/TabViewItem.h Outdated Show resolved Hide resolved
@StephenLPeters StephenLPeters added area-TabView team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Apr 1, 2020
@kmahone
Copy link
Member

kmahone commented Apr 3, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@kmahone
Copy link
Member

kmahone commented Apr 3, 2020

Looks like this change introduced a number of test failures:

Failing tests:
InteractionTests.TabViewTests.TabSizeAndScrollButtonsTest
InteractionTests.TabViewTests.CloseSelectionTest
InteractionTests.TabViewTests.GamePadTest
InteractionTests.TabViewTests.KeyboardTest
InteractionTests.TabViewTests.SelectionTest

@stmoy
Copy link
Contributor

stmoy commented Apr 30, 2020

If you look closely you will see that Edge does have it, its very subtle but still there.

Agreed, it's very subtle. I'm not opposed to adding it, but we're so close to finishing this PR that I'd prefer to get this one over the finish line and not block on adding them to the hover states.

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:

@ranjeshj
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@marcelwgn
Copy link
Collaborator Author

I don't think this test failure is related to the TabView, so maybe we can try a rerun?

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StephenLPeters StephenLPeters merged commit 98a6b74 into microsoft:master May 19, 2020
@marcelwgn marcelwgn deleted the tabview-inset-radii branch May 19, 2020 17:33
@MikeHillberg
Copy link
Contributor

@chingucoding, why is it necessary to set the margins on the two Paths (and thus the two new APIs)?

@marcelwgn
Copy link
Collaborator Author

@MikeHillberg Since the two paths need to render outside of the TabViewItem, we need a negative margin. Since the two paths are sized based on the OverlayCornerRadius, we need to calculate the negative margin based off of that. The only two ways to that is either use a converter or add that to the TemplateSettings.

@MikeHillberg
Copy link
Contributor

@chingucoding, that makes sense, thanks!

What's difficult is that it violates the separation between the view (template) and the control. The control is returning the correct value for this property only because it knows that the template is using OverlayCornerRadius.

@marcelwgn
Copy link
Collaborator Author

Yeah that's problematic. However what other way is there to handle this? Unfortunately, there isn't a CornerRadius property on the TabViewItem which we could leverage here. All the rounded corners are deeply rooted inside the template. We could get the corner radius from the "TabContainer", however we then would rely on the template providing this specific part of the template and visual tree lookups are generally expensive.

@MikeHillberg
Copy link
Contributor

This is a nice demonstration of why we need code support in control templates. The other way we've handled this, as you mentioned, is with a converter. CornerRadiusFilterConverter is almost the same, where we needed to pull a component(s) out of a struct. We could do that here, the difference being that it support a Thickness and negation.

@marcelwgn
Copy link
Collaborator Author

@ranjeshj @teaP @StephenLPeters Was there a reason we chose to not use a custom converter here? I think it was because it would be quite specific, but not sure.

@MikeHillberg Would it be better if we switch to a custom converter here?

@MikeHillberg
Copy link
Contributor

I think a custom converter would be better.

Overall, the goal is for a Control and ControlTemplate to be a model and a view, so following normal model/view separation and motivations and guidelines. In the page or user control scenario, we allow for code-behind in the view, and we have similar though limited support in data template as well. But we currently have no capability in control templates. So in the interim, when we need some code in a control template, we use template settings or converters, and no clear guidance about when to use which. I generally prefer template settings because they're lighter weight, but I think converters are preferable when necessary to maintain the view's separation.

@StephenLPeters
Copy link
Contributor

It wouldn't be the first rather specific converter in Winui, See the CornerRadiusToThicknessConverter used by teaching tip. I think a converter makes sense here. Even though it is likely to only be used by tabview the calculations that the converter would be doing is cleanly separated from the tab view and thus i think the separation of the code makes sense

@ranjeshj
Copy link
Contributor

ranjeshj commented Jul 2, 2020

@MikeHillberg @StephenLPeters Can we make this as the new guidance no matter how specific the converter is ? I like the separation so that we don't end up with template specific properties on the control API surface.

@ranjeshj
Copy link
Contributor

ranjeshj commented Jul 3, 2020

@StephenLPeters @MikeHillberg Looks like we are in agreement that this should be a converter. @chingucoding would you like to make that change ?

@marcelwgn
Copy link
Collaborator Author

Sure I'll make that change @ranjeshj.

@MikeHillberg
Copy link
Contributor

Thanks @chingucoding!

ghost pushed a commit to microsoft/terminal that referenced this pull request Jul 7, 2020
See: https://github.com/microsoft/microsoft-ui-xaml/releases/tag/v2.5.0-prerelease.200609001

> ### Notable Changes:
> 
>     Resize tab view items only once the pointer has left the TabViewItem strip (microsoft/microsoft-ui-xaml#2569)
>     Align TabView visuals with Edge (microsoft/microsoft-ui-xaml#2201)
>     Fix background of MenuFlyout in white high contrast (microsoft/microsoft-ui-xaml#2446)
>     TabView: Make TabViewItem consume the TabViewItemHeaderForeground theme resource (microsoft/microsoft-ui-xaml#2348)
>     TabView: Add tooltips to its scrolling buttons. (microsoft/microsoft-ui-xaml#2369)


* [x] Related to #5360 (@jtippet confirms that this alone does not close it.)
* [x] I work here
donno2048 added a commit to donno2048/terminal that referenced this pull request Sep 28, 2020
See: https://github.com/microsoft/microsoft-ui-xaml/releases/tag/v2.5.0-prerelease.200609001

> ### Notable Changes:
> 
>     Resize tab view items only once the pointer has left the TabViewItem strip (microsoft/microsoft-ui-xaml#2569)
>     Align TabView visuals with Edge (microsoft/microsoft-ui-xaml#2201)
>     Fix background of MenuFlyout in white high contrast (microsoft/microsoft-ui-xaml#2446)
>     TabView: Make TabViewItem consume the TabViewItemHeaderForeground theme resource (microsoft/microsoft-ui-xaml#2348)
>     TabView: Add tooltips to its scrolling buttons. (microsoft/microsoft-ui-xaml#2369)


* [x] Related to #5360 (@jtippet confirms that this alone does not close it.)
* [x] I work here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-TabView team-Controls Issue for the Controls team
Projects
None yet
Development

Successfully merging this pull request may close these issues.