-
Notifications
You must be signed in to change notification settings - Fork 683
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
Align TabView visuals with Edge #2201
Conversation
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. |
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 |
And does that affect the paths used for the bottom inset corners? |
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.idl
Outdated
@@ -182,8 +182,12 @@ unsealed runtimeclass TabViewItemTemplateSettings : Windows.UI.Xaml.DependencyOb | |||
TabViewItemTemplateSettings(); | |||
|
|||
Windows.UI.Xaml.Controls.IconElement IconElement; | |||
Windows.UI.Xaml.Thickness LeftInsetRadiusMargin; |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Looks like this change introduced a number of test failures:
|
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
I don't think this test failure is related to the TabView, so maybe we can try a rerun? |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@chingucoding, why is it necessary to set the margins on the two Paths (and thus the two new APIs)? |
@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. |
@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. |
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. |
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. |
@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? |
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. |
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 |
@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. |
@StephenLPeters @MikeHillberg Looks like we are in agreement that this should be a converter. @chingucoding would you like to make that change ? |
Sure I'll make that change @ranjeshj. |
Thanks @chingucoding! |
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
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
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):