Skip to content

Commit

Permalink
Merge pull request #7500 from MartinZikmund/dev/mazi/ratingcontrol-up…
Browse files Browse the repository at this point in the history
…dates

`RatingControl` updates, Fluent theme resources update
  • Loading branch information
mergify[bot] authored Nov 20, 2021
2 parents 8816149 + f162357 commit 2d35d99
Show file tree
Hide file tree
Showing 18 changed files with 473 additions and 945 deletions.
67 changes: 43 additions & 24 deletions src/Uno.UI.FluentTheme.v1/themeresources_v1.xaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<!-- MUX Reference RatingControl.xaml, commit 29e8b9d -->
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Microsoft.UI.Xaml.Controls">

<Style TargetType="local:RatingControl">
<Setter Property="Height" Value="32"/>
<!-- 9794813: retire these two properties as customisation points once all resource keys available -->
Expand All @@ -21,7 +22,7 @@
<VisualState.Setters>
<Setter Target="ForegroundContentPresenter.Foreground" Value="{ThemeResource RatingControlDisabledSelectedForeground}"/>
</VisualState.Setters>
</VisualState>
</VisualState>
<VisualState x:Name="Placeholder">
<VisualState.Setters>
<Setter Target="ForegroundContentPresenter.Foreground" Value="{ThemeResource RatingControlPlaceholderForeground}"/>
Expand All @@ -35,7 +36,7 @@
<VisualState x:Name="PointerOverUnselected">
<VisualState.Setters>
<Setter Target="ForegroundContentPresenter.Foreground" Value="{ThemeResource RatingControlPointerOverUnselectedForeground}"/>
</VisualState.Setters>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Set">
<VisualState.Setters>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<!-- MUX Reference RatingControl_themeresources.xaml, commit 1b66f00 -->
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Expand Down
14 changes: 12 additions & 2 deletions src/Uno.UI.FluentTheme.v2/themeresources_v2.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22099,7 +22099,7 @@
<ColumnDefinition Width="Auto" x:Name="AddButtonColumn" />
<ColumnDefinition Width="*" x:Name="RightContentColumn" />
</Grid.ColumnDefinitions>
<Border BorderBrush="{ThemeResource TabViewBorderBrush}" BorderThickness="1" Height="1" Grid.Column="1" Grid.ColumnSpan="2" VerticalAlignment="Bottom" />
<Border BorderBrush="{ThemeResource TabViewBorderBrush}" BorderThickness="1" Height="1" Grid.ColumnSpan="4" VerticalAlignment="Bottom" />
<ContentPresenter Grid.Column="0" x:Name="LeftContentPresenter" Content="{TemplateBinding TabStripHeader}" ContentTemplate="{TemplateBinding TabStripHeaderTemplate}" />
<primitives:TabViewListView Grid.Column="1" x:Name="TabListView" Padding="{TemplateBinding Padding}" CanReorderItems="{TemplateBinding CanReorderTabs}" CanDragItems="{TemplateBinding CanDragTabs}" AllowDrop="{TemplateBinding AllowDropTabs}" ItemsSource="{TemplateBinding TabItemsSource}" ItemTemplate="{TemplateBinding TabItemTemplate}" ItemTemplateSelector="{TemplateBinding TabItemTemplateSelector}" />
<Border Visibility="{Binding IsAddTabButtonVisible, RelativeSource={RelativeSource TemplatedParent}}" Grid.Column="2" Padding="{ThemeResource TabViewItemAddButtonContainerPadding}" VerticalAlignment="Bottom">
Expand Down Expand Up @@ -22284,6 +22284,7 @@
</Setter>
</Style>
<Style TargetType="controls:TabViewItem">
<Setter Property="Background" Value="{ThemeResource TabViewItemHeaderBackground}" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}" />
<Setter Property="MinHeight" Value="{ThemeResource TabViewItemMinHeight}" />
Expand Down Expand Up @@ -22497,13 +22498,22 @@
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
<VisualStateGroup>
<VisualState x:Name="ForegroundNotSet" />
<VisualState x:Name="ForegroundSet">
<VisualState.Setters>
<Setter Target="IconControl.Foreground" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Foreground}" />
<Setter Target="ContentPresenter.Foreground" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Foreground}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Path x:Name="LeftRadiusRenderArc" x:Load="False" Fill="{ThemeResource CardStrokeColorDefault}" VerticalAlignment="Bottom" Visibility="Collapsed" Margin="-4,0,0,0" Height="4" Width="4" Data="M4 0C4 1.19469 3.47624 2.26706 2.64582 3H0C1.65685 3 3 1.65685 3 0H4Z" />
<Path x:Name="LeftRadiusRenderTriangle" x:Load="False" Fill="{ThemeResource TabViewItemHeaderBackgroundSelected}" VerticalAlignment="Bottom" Margin="-4,0,0,0" Visibility="Collapsed" Data="M0 4H4V0C4 2.20914 2.20914 4 0 4Z" />
<Path x:Name="RightRadiusRenderArc" x:Load="False" Grid.Column="2" Visibility="Collapsed" Fill="{ThemeResource CardStrokeColorDefault}" VerticalAlignment="Bottom" Margin="0,0,-4,0" Height="4" Width="4" Data="M0 0C0 1.19469 0.523755 2.26706 1.35418 3H4C2.34315 3 1 1.65685 1 0H0Z" />
<Path x:Name="RightRadiusRenderTriangle" x:Load="False" Grid.Column="2" Visibility="Collapsed" Fill="{ThemeResource TabViewItemHeaderBackgroundSelected}" VerticalAlignment="Bottom" Margin="0,0,-4,0" Data="M4 4H0V0C0 2.20914 1.79086 4 4 4Z" />
<Border x:Name="TabSeparator" HorizontalAlignment="Right" Width="1" Grid.Column="1" BorderBrush="{ThemeResource TabViewItemSeparator}" BorderThickness="1" Margin="{ThemeResource TabViewItemSeparatorMargin}" />
<Grid x:Name="TabContainer" Grid.Column="1" Background="{ThemeResource TabViewItemHeaderBackground}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Control.IsTemplateFocusTarget="True" Padding="{ThemeResource TabViewItemHeaderPadding}" contract7Present:CornerRadius="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CornerRadius, Converter={StaticResource TopCornerRadiusFilterConverter}}" contract7NotPresent:CornerRadius="{Binding Source={ThemeResource OverlayCornerRadius}, Converter={StaticResource TopCornerRadiusFilterConverter}}" FocusVisualMargin="{TemplateBinding FocusVisualMargin}">
<Grid x:Name="TabContainer" Grid.Column="1" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Control.IsTemplateFocusTarget="True" Padding="{ThemeResource TabViewItemHeaderPadding}" contract7Present:CornerRadius="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CornerRadius, Converter={StaticResource TopCornerRadiusFilterConverter}}" contract7NotPresent:CornerRadius="{Binding Source={ThemeResource OverlayCornerRadius}, Converter={StaticResource TopCornerRadiusFilterConverter}}" FocusVisualMargin="{TemplateBinding FocusVisualMargin}">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="IconColumn" Width="Auto" />
<ColumnDefinition Width="*" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
// MUX Reference RatingControlTests.h, commit e7e0823

using System;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
// MUX Reference RatingControl.h, commit b853109

#nullable enable

using Uno.Disposables;
using Uno.UI.Helpers.WinUI;
using Windows.UI.Composition;
using Windows.UI.Xaml.Controls;

namespace Microsoft.UI.Xaml.Controls;

public partial class RatingControl
{
private bool IsItemInfoPresentAndFontInfo()
{
return m_infoType == RatingInfoType.Font;
}
private bool IsItemInfoPresentAndImageInfo()
{
return m_infoType == RatingInfoType.Image;
}

// Private members
private TextBlock? m_captionTextBlock = null;

private CompositionPropertySet? m_sharedPointerPropertySet = null;

private StackPanel? m_backgroundStackPanel = null;
private StackPanel? m_foregroundStackPanel = null;

private bool m_isPointerOver = false;
private bool m_isPointerDown = false;
private double m_mousePercentage = 0.0;

private RatingInfoType m_infoType = RatingInfoType.Font;

// Holds the value of the Rating control at the moment of engagement,
// used to handle cancel-disengagements where we reset the value.
private double m_preEngagementValue = 0.0;
private bool m_disengagedWithA = false;
private bool m_shouldDiscardValue = true;

private long m_fontFamilyChangedToken;

private DispatcherHelper? m_dispatcherHelper = null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,33 +48,12 @@ public partial class RatingControl : Control

private const int c_noValueSetSentinel = -1;

private static UISettings _uiSettings = null;

private DispatcherHelper m_dispatcherHelper;

// Private members
private TextBlock m_captionTextBlock;

private CompositionPropertySet m_sharedPointerPropertySet;

private StackPanel m_backgroundStackPanel;
private StackPanel m_foregroundStackPanel;

private bool m_isPointerOver = false;
private bool m_isPointerDown = false;
private double m_mousePercentage = 0.0;

private RatingInfoType m_infoType = RatingInfoType.Font;
private double m_preEngagementValue = 0.0;
private bool m_disengagedWithA = false;
private bool m_shouldDiscardValue = true;
private long m_fontFamilyChangedToken;

/// <summary>
/// Initializes a new instance of the RatingControl class.
/// </summary>
public RatingControl()
{
// Uno specific: Needs to be initialized in constructor, as "this" is not available in readonly field initializer
m_dispatcherHelper = new DispatcherHelper(this);
//__RP_Marker_ClassById(RuntimeProfiler.ProfId_RatingControl);

Expand Down Expand Up @@ -365,6 +344,13 @@ private void UpdateRatingItemsAppearance()

private void ApplyScaleExpressionAnimation(UIElement uiElement, int starIndex)
{
var scaleTransform = new ScaleTransform()
{
ScaleX = 0.5,
ScaleY = 0.5
};
uiElement.RenderTransform = scaleTransform;
uiElement.RenderTransformOrigin = new Point(0.5, 0.5);
//TODO: Uno Specific - Expression animations are not supported yet

//Visual uiElementVisual = ElementCompositionPreview.GetElementVisual(uiElement);
Expand Down Expand Up @@ -1211,22 +1197,12 @@ private void OnTextScaleFactorChanged(UISettings setting, object args)
}


private UISettings _uiSettings;

private UISettings GetUISettings()
{
_uiSettings = _uiSettings ?? new UISettings();
return _uiSettings;
}

// Header file

private bool IsItemInfoPresentAndFontInfo()
{
return m_infoType == RatingInfoType.Font;
}

private bool IsItemInfoPresentAndImageInfo()
{
return m_infoType == RatingInfoType.Image;
}
}
}
Loading

0 comments on commit 2d35d99

Please sign in to comment.