Skip to content

Commit

Permalink
CornerRadius updates/fixes (#1165)
Browse files Browse the repository at this point in the history
* CornerRadius updates

* Update CornerRadiusPage

* Update default values
  • Loading branch information
kaiguo authored Aug 21, 2019
1 parent 532b504 commit 893bb1c
Show file tree
Hide file tree
Showing 13 changed files with 272 additions and 103 deletions.
10 changes: 9 additions & 1 deletion dev/AutoSuggestBox/APITests/AutoSuggestBoxTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Windows.UI.Xaml.Media;
using System.Linq;
using System.Collections.Generic;
using MUXControlsTestApp;

#if USING_TAEF
using WEX.TestExecution;
Expand Down Expand Up @@ -64,9 +65,16 @@ public void VerifyAutoSuggestBoxCornerRadius()
var textBox = TestUtilities.FindDescendents<TextBox>(autoSuggestBox).Where(e => e.Name == "TextBox").Single();
Verify.AreEqual(new CornerRadius(2, 2, 0, 0), textBox.CornerRadius);

var overlayCornerRadius = new CornerRadius(0, 0, 0, 0);
var radius = App.Current.Resources["OverlayCornerRadius"];
if (radius != null)
{
overlayCornerRadius = (CornerRadius)radius;
}
var popup = VisualTreeHelper.GetOpenPopups(Window.Current).Last();
var popupBorder = popup.Child as Border;
Verify.AreEqual(new CornerRadius(0, 0, 2, 2), popupBorder.CornerRadius);

Verify.AreEqual(new CornerRadius(0, 0, overlayCornerRadius.BottomRight, overlayCornerRadius.BottomLeft), popupBorder.CornerRadius);
});
}

Expand Down
3 changes: 1 addition & 2 deletions dev/AutoSuggestBox/AutoSuggestBoxHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,11 @@ void AutoSuggestBoxHelper::OnAutoSuggestBoxLoaded(const winrt::IInspectable& sen
void AutoSuggestBoxHelper::UpdateCornerRadius(const winrt::AutoSuggestBox& autoSuggestBox, bool isPopupOpen)
{
auto textBoxRadius = unbox_value<winrt::CornerRadius>(ResourceLookup(autoSuggestBox, box_value(c_controlCornerRadiusKey)));
auto popupRadius = textBoxRadius;
auto popupRadius = unbox_value<winrt::CornerRadius>(ResourceLookup(autoSuggestBox, box_value(c_overlayCornerRadiusKey)));

if (winrt::IControl7 autoSuggextBoxControl7 = autoSuggestBox)
{
textBoxRadius = autoSuggextBoxControl7.CornerRadius();
popupRadius = autoSuggextBoxControl7.CornerRadius();
}

if (isPopupOpen)
Expand Down
3 changes: 1 addition & 2 deletions dev/AutoSuggestBox/AutoSuggestBox_themeresources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,7 @@
BorderThickness="{ThemeResource AutoSuggestListBorderThemeThickness}"
BorderBrush="{ThemeResource AutoSuggestBoxSuggestionsListBorderBrush}"
Background="{ThemeResource AutoSuggestBoxSuggestionsListBackground}"
contract7Present:CornerRadius="{TemplateBinding CornerRadius}"
contract7NotPresent:CornerRadius="{ThemeResource OverlayCornerRadius}">
CornerRadius="{ThemeResource OverlayCornerRadius}">
<Border.RenderTransform>
<contract7NotPresent:TranslateTransform x:Name="UpwardTransform" />
</Border.RenderTransform>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@
DayOfWeekFormat="{TemplateBinding DayOfWeekFormat}"
CalendarIdentifier="{TemplateBinding CalendarIdentifier}"
IsOutOfScopeEnabled="{TemplateBinding IsOutOfScopeEnabled}"
IsGroupLabelVisible="{TemplateBinding IsGroupLabelVisible}" />
IsGroupLabelVisible="{TemplateBinding IsGroupLabelVisible}"
contract7Present:CornerRadius="{ThemeResource OverlayCornerRadius}" />
</Flyout>
</FlyoutBase.AttachedFlyout>

Expand Down
17 changes: 15 additions & 2 deletions dev/ComboBox/APITests/ComboBoxTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
using System.Linq;
using MUXControlsTestApp;

#if USING_TAEF
using WEX.TestExecution;
Expand Down Expand Up @@ -49,9 +50,15 @@ public void VerifyComboBoxOverlayCornerRadius()
var background = TestUtilities.FindDescendents<Border>(comboBox).Where(e => e.Name == "Background").Single();
Verify.AreEqual(new CornerRadius(2, 2, 2, 2), background.CornerRadius);

var overlayCornerRadius = new CornerRadius(0, 0, 0, 0);
var radius = App.Current.Resources["OverlayCornerRadius"];
if (radius != null)
{
overlayCornerRadius = (CornerRadius)radius;
}
var popup = VisualTreeHelper.GetOpenPopups(Window.Current).Last();
var popupBorder = TestUtilities.FindDescendents<Border>(popup).Where(e => e.Name=="PopupBorder").Single();
Verify.AreEqual(new CornerRadius(2, 2, 2, 2), popupBorder.CornerRadius);
Verify.AreEqual(overlayCornerRadius, popupBorder.CornerRadius);
});
}

Expand All @@ -78,9 +85,15 @@ public void VerifyComboBoxEditModeCornerRadius()
var editableText = TestUtilities.FindDescendents<TextBox>(comboBox).Where(e => e.Name == "EditableText").Single();
Verify.AreEqual(new CornerRadius(2, 2, 0, 0), editableText.CornerRadius);

var overlayCornerRadius = new CornerRadius(0, 0, 0, 0);
var radius = App.Current.Resources["OverlayCornerRadius"];
if (radius != null)
{
overlayCornerRadius = (CornerRadius)radius;
}
var popup = VisualTreeHelper.GetOpenPopups(Window.Current).Last();
var popupBorder = TestUtilities.FindDescendents<Border>(popup).Where(e => e.Name == "PopupBorder").Single();
Verify.AreEqual(new CornerRadius(0, 0, 2, 2), popupBorder.CornerRadius);
Verify.AreEqual(new CornerRadius(0, 0, overlayCornerRadius.BottomRight, overlayCornerRadius.BottomLeft), popupBorder.CornerRadius);
});
}

Expand Down
2 changes: 1 addition & 1 deletion dev/ComboBox/ComboBoxHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void ComboBoxHelper::UpdateCornerRadius(const winrt::ComboBox& comboBox, bool is
auto cornerRadiusConverter = winrt::make_self<CornerRadiusFilterConverter>();

auto popupRadiusFilter = isOpenDown ? winrt::CornerRadiusFilterKind::Bottom : winrt::CornerRadiusFilterKind::Top;
popupRadius = cornerRadiusConverter->Convert(textBoxRadius, popupRadiusFilter);
popupRadius = cornerRadiusConverter->Convert(popupRadius, popupRadiusFilter);

auto textBoxRadiusFilter = isOpenDown ? winrt::CornerRadiusFilterKind::Top : winrt::CornerRadiusFilterKind::Bottom;
textBoxRadius = cornerRadiusConverter->Convert(textBoxRadius, textBoxRadiusFilter);
Expand Down
3 changes: 1 addition & 2 deletions dev/ComboBox/ComboBox_themeresources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,7 @@
Margin="0,-1,0,-1"
Padding="{ThemeResource ComboBoxDropdownBorderPadding}"
HorizontalAlignment="Stretch"
contract7Present:CornerRadius="{TemplateBinding CornerRadius}"
contract7NotPresent:CornerRadius="{ThemeResource OverlayCornerRadius}">
CornerRadius="{ThemeResource OverlayCornerRadius}">
<ScrollViewer x:Name="ScrollViewer"
Foreground="{ThemeResource ComboBoxDropDownForeground}"
MinWidth="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.DropDownContentMinWidth}"
Expand Down
12 changes: 6 additions & 6 deletions dev/CommonStyles/CornerRadius_themeresources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
xmlns:primitives="using:Microsoft.UI.Xaml.Controls.Primitives">
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<CornerRadius x:Key="ControlCornerRadius">0,0,0,0</CornerRadius>
<CornerRadius x:Key="OverlayCornerRadius">0,0,0,0</CornerRadius>
<CornerRadius x:Key="ControlCornerRadius">2,2,2,2</CornerRadius>
<CornerRadius x:Key="OverlayCornerRadius">4,4,4,4</CornerRadius>
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<CornerRadius x:Key="ControlCornerRadius">0,0,0,0</CornerRadius>
<CornerRadius x:Key="OverlayCornerRadius">0,0,0,0</CornerRadius>
<CornerRadius x:Key="ControlCornerRadius">2,2,2,2</CornerRadius>
<CornerRadius x:Key="OverlayCornerRadius">4,4,4,4</CornerRadius>
</ResourceDictionary>
<ResourceDictionary x:Key="Light">
<CornerRadius x:Key="ControlCornerRadius">0,0,0,0</CornerRadius>
<CornerRadius x:Key="OverlayCornerRadius">0,0,0,0</CornerRadius>
<CornerRadius x:Key="ControlCornerRadius">2,2,2,2</CornerRadius>
<CornerRadius x:Key="OverlayCornerRadius">4,4,4,4</CornerRadius>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

Expand Down
44 changes: 40 additions & 4 deletions dev/CommonStyles/MediaTransportControls_themeresources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:contract7Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,7)"
xmlns:contract7NotPresent="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractNotPresent(Windows.Foundation.UniversalApiContract,7)"
xmlns:contract8Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,8)">
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
Expand Down Expand Up @@ -69,6 +71,7 @@
<Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}" />
<Setter Property="FocusVisualMargin" Value="-7,0,-7,0" />
<Setter Property="IsFocusEngagementEnabled" Value="True" />
<contract7Present:Setter Property="CornerRadius" Value="{ThemeResource ControlCornerRadius}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Slider">
Expand Down Expand Up @@ -231,9 +234,25 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="18" />
</Grid.RowDefinitions>
<Rectangle x:Name="HorizontalTrackRect" Fill="{TemplateBinding Background}" Height="{ThemeResource SliderTrackThemeHeight}" Grid.Row="1" Grid.ColumnSpan="3" />
<Rectangle
x:Name="HorizontalTrackRect"
Fill="{TemplateBinding Background}"
Height="{ThemeResource SliderTrackThemeHeight}"
Grid.Row="1"
Grid.ColumnSpan="3"
contract7Present:RadiusX="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CornerRadius.TopLeft}"
contract7Present:RadiusY="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CornerRadius.BottomRight}"
contract7NotPresent:RadiusX="{Binding Source={ThemeResource ControlCornerRadius}, Path=TopLeft}"
contract7NotPresent:RadiusY="{Binding Source={ThemeResource ControlCornerRadius}, Path=BottomRight}" />
<ProgressBar x:Name="DownloadProgressIndicator" Style="{StaticResource MediaSliderProgressBarStyle}" Grid.Row="1" Grid.ColumnSpan="3" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
<Rectangle x:Name="HorizontalDecreaseRect" Fill="{TemplateBinding Foreground}" Grid.Row="1" />
<Rectangle
x:Name="HorizontalDecreaseRect"
Fill="{TemplateBinding Foreground}"
Grid.Row="1"
contract7Present:RadiusX="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CornerRadius.TopLeft}"
contract7Present:RadiusY="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CornerRadius.BottomRight}"
contract7NotPresent:RadiusX="{Binding Source={ThemeResource ControlCornerRadius}, Path=TopLeft}"
contract7NotPresent:RadiusY="{Binding Source={ThemeResource ControlCornerRadius}, Path=BottomRight}" />
<TickBar x:Name="TopTickBar" Visibility="Collapsed" Fill="{ThemeResource SliderTickBarFill}" Height="{ThemeResource SliderOutsideTickBarThemeHeight}" VerticalAlignment="Bottom" Margin="0,0,0,4" Grid.ColumnSpan="3" />
<TickBar x:Name="HorizontalInlineTickBar" Visibility="Collapsed" Fill="{ThemeResource SliderInlineTickBarFill}" Height="{ThemeResource SliderTrackThemeHeight}" Grid.Row="1" Grid.ColumnSpan="3" />
<TickBar x:Name="BottomTickBar" Visibility="Collapsed" Fill="{ThemeResource SliderTickBarFill}" Height="{ThemeResource SliderOutsideTickBarThemeHeight}" VerticalAlignment="Top" Margin="0,4,0,0" Grid.Row="2" Grid.ColumnSpan="3" />
Expand Down Expand Up @@ -264,8 +283,25 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="18" />
</Grid.ColumnDefinitions>
<Rectangle x:Name="VerticalTrackRect" Fill="{TemplateBinding Background}" Width="{ThemeResource SliderTrackThemeHeight}" Grid.Column="1" Grid.RowSpan="3" />
<Rectangle x:Name="VerticalDecreaseRect" Fill="{TemplateBinding Foreground}" Grid.Column="1" Grid.Row="2" />
<Rectangle
x:Name="VerticalTrackRect"
Fill="{TemplateBinding Background}"
Width="{ThemeResource SliderTrackThemeHeight}"
Grid.Column="1"
Grid.RowSpan="3"
contract7Present:RadiusX="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CornerRadius.TopLeft}"
contract7Present:RadiusY="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CornerRadius.BottomRight}"
contract7NotPresent:RadiusX="{Binding Source={ThemeResource ControlCornerRadius}, Path=TopLeft}"
contract7NotPresent:RadiusY="{Binding Source={ThemeResource ControlCornerRadius}, Path=BottomRight}" />
<Rectangle
x:Name="VerticalDecreaseRect"
Fill="{TemplateBinding Foreground}"
Grid.Column="1"
Grid.Row="2"
contract7Present:RadiusX="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CornerRadius.TopLeft}"
contract7Present:RadiusY="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CornerRadius.BottomRight}"
contract7NotPresent:RadiusX="{Binding Source={ThemeResource ControlCornerRadius}, Path=TopLeft}"
contract7NotPresent:RadiusY="{Binding Source={ThemeResource ControlCornerRadius}, Path=BottomRight}" />
<TickBar x:Name="LeftTickBar" Visibility="Collapsed" Fill="{ThemeResource SliderTickBarFill}" Width="{ThemeResource SliderOutsideTickBarThemeHeight}" HorizontalAlignment="Right" Margin="0,0,4,0" Grid.RowSpan="3" />
<TickBar x:Name="VerticalInlineTickBar" Visibility="Collapsed" Fill="{ThemeResource SliderInlineTickBarFill}" Width="{ThemeResource SliderTrackThemeHeight}" Grid.Column="1" Grid.RowSpan="3" />
<TickBar x:Name="RightTickBar" Visibility="Collapsed" Fill="{ThemeResource SliderTickBarFill}" Width="{ThemeResource SliderOutsideTickBarThemeHeight}" HorizontalAlignment="Left" Margin="4,0,0,0" Grid.Column="2" Grid.RowSpan="3" />
Expand Down
Loading

0 comments on commit 893bb1c

Please sign in to comment.