From 9b84510ec9f89e74dfbd7a513efced006f5315b5 Mon Sep 17 00:00:00 2001 From: Martin Zikmund Date: Wed, 22 Nov 2023 12:46:01 +0100 Subject: [PATCH] chore: Adjust TimePicker logic for Skia # Conflicts: # src/Uno.UI/UI/Xaml/Media/ThemeShadow.cs --- .../Controls/Primitives/PickerFlyoutBase.cs | 2 +- .../Controls/TimePicker/TimePicker.nonref.cs | 1 + .../TimePicker/TimePicker.partial.mux.cs | 6 +-- .../TimePicker/TimePickerFlyout.Properties.cs | 6 +-- .../TimePickerFlyout.partial.mux.cs | 6 +-- .../TimePickerFlyoutPresenter.partial.mux.cs | 6 +-- src/Uno.UI/UI/Xaml/Media/ThemeShadow.cs | 41 ++++++++++--------- 7 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/Uno.UI/UI/Xaml/Controls/Primitives/PickerFlyoutBase.cs b/src/Uno.UI/UI/Xaml/Controls/Primitives/PickerFlyoutBase.cs index 86b30f785394..488c50462270 100644 --- a/src/Uno.UI/UI/Xaml/Controls/Primitives/PickerFlyoutBase.cs +++ b/src/Uno.UI/UI/Xaml/Controls/Primitives/PickerFlyoutBase.cs @@ -24,7 +24,7 @@ public static void SetTitle(DependencyObject element, string value) element.SetValue(TitleProperty, value); } - protected virtual void OnConfirmed() => throw new InvalidOperationException(); + protected virtual void OnConfirmed() => Hide(); protected virtual bool ShouldShowConfirmationButtons() => throw new InvalidOperationException(); diff --git a/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePicker.nonref.cs b/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePicker.nonref.cs index 37439548cb59..e6ec9a6d2957 100644 --- a/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePicker.nonref.cs +++ b/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePicker.nonref.cs @@ -45,6 +45,7 @@ public TimePicker() ResourceResolver.ApplyResource(this, LightDismissOverlayBackgroundProperty, "TimePickerLightDismissOverlayBackground", isThemeResourceExtension: true, isHotReloadSupported: false); DefaultStyleKey = typeof(TimePicker); + InitPartial(); } #region Time DependencyProperty diff --git a/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePicker.partial.mux.cs b/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePicker.partial.mux.cs index 1bed94e108bf..bd03bdd2db74 100644 --- a/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePicker.partial.mux.cs +++ b/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePicker.partial.mux.cs @@ -77,6 +77,7 @@ public TimePicker() m_reactionToSelectionChangeAllowed = false; m_defaultTime = new TimeSpan(GetNullTimeSentinelValue()); m_currentTime = new TimeSpan(GetNullTimeSentinelValue()); + InitPartial(); PrepareState(); } @@ -120,11 +121,6 @@ private void PrepareState() RefreshSetup(); Loaded += OnLoaded; - - if (pCurrentWindow is not null) - { - v - } } private void OnLoaded(object sender, RoutedEventArgs e) diff --git a/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePickerFlyout.Properties.cs b/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePickerFlyout.Properties.cs index cc2cb8f98788..215ef932753a 100644 --- a/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePickerFlyout.Properties.cs +++ b/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePickerFlyout.Properties.cs @@ -22,7 +22,7 @@ public string ClockIdentifier typeof(string), typeof(TimePickerFlyout), new FrameworkPropertyMetadata( - defaultValue: (string)Windows.Globalization.ClockIdentifiers.TwelveHour, + defaultValue: (string)TimePickerFlyout.GetDefaultClockIdentifier(), options: FrameworkPropertyMetadataOptions.None) ); @@ -38,7 +38,7 @@ public int MinuteIncrement typeof(int), typeof(TimePickerFlyout), new FrameworkPropertyMetadata( - defaultValue: (int)1, + defaultValue: (int)TimePickerFlyout.GetDefaultMinuteIncrement(), options: FrameworkPropertyMetadataOptions.None) ); @@ -54,7 +54,7 @@ public TimeSpan Time typeof(TimeSpan), typeof(TimePickerFlyout), new FrameworkPropertyMetadata( - defaultValue: (TimeSpan)DateTime.Now.TimeOfDay, + defaultValue: (TimeSpan)TimePickerFlyout.GetDefaultTime(), options: FrameworkPropertyMetadataOptions.None) ); diff --git a/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePickerFlyout.partial.mux.cs b/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePickerFlyout.partial.mux.cs index a73465bffdd5..963235570f4d 100644 --- a/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePickerFlyout.partial.mux.cs +++ b/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePickerFlyout.partial.mux.cs @@ -230,7 +230,7 @@ private void OnKeyDown(object pSender, KeyRoutedEventArgs pEventArgs) } } - private object GetDefaultTime() + private static TimeSpan GetDefaultTime() { TimeSpan retTimeSpan = default; @@ -276,12 +276,12 @@ private object GetDefaultTime() return retTimeSpan; } - private object GetDefaultClockIdentifier() + private static string GetDefaultClockIdentifier() { var spFormatter = new DateTimeFormatter(s_strHourFormat); return spFormatter.Clock; } - private object GetDefaultMinuteIncrement() => 1; + private static int GetDefaultMinuteIncrement() => 1; } diff --git a/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePickerFlyoutPresenter.partial.mux.cs b/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePickerFlyoutPresenter.partial.mux.cs index 1afc249f28f6..99057c61a81c 100644 --- a/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePickerFlyoutPresenter.partial.mux.cs +++ b/src/Uno.UI/UI/Xaml/Controls/TimePicker/TimePickerFlyoutPresenter.partial.mux.cs @@ -53,9 +53,9 @@ partial class TimePickerFlyoutPresenter private const string _strHourFormat = "{hour.integer(1)}"; private const string _strMinuteFormat = "{minute.integer(2)}"; private const string _strPeriodFormat = "{period.abbreviated(2)}"; - private const long _timeSpanTicksPerMinute = 60000000; - private const long _timeSpanTicksPerHour = 3600000000; - private const long _timeSpanTicksPerDay = 86400000000; + private const long _timeSpanTicksPerMinute = 600000000; + private const long _timeSpanTicksPerHour = 36000000000; + private const long _timeSpanTicksPerDay = 864000000000; internal const int _periodCoercionOffset = 12; private const string _firstPickerHostName = "FirstPickerHost"; private const string _secondPickerHostName = "SecondPickerHost"; diff --git a/src/Uno.UI/UI/Xaml/Media/ThemeShadow.cs b/src/Uno.UI/UI/Xaml/Media/ThemeShadow.cs index b3e380a64495..94ed87a954b8 100644 --- a/src/Uno.UI/UI/Xaml/Media/ThemeShadow.cs +++ b/src/Uno.UI/UI/Xaml/Media/ThemeShadow.cs @@ -1,25 +1,28 @@ -namespace Microsoft.UI.Xaml.Media +namespace Microsoft.UI.Xaml.Media; + +/// +/// A ThemeShadow is a preconfigured shadow effect that can be applied to any XAML element to draw shadows appropriately based on x,y,z coordinates. +/// ThemeShadow also automatically adjusts for other environmental specifications. +/// - Adapts to changes in lighting, user theme, app environment, and shell. +/// - Shadows elements automatically based on their elevation. +/// - Keeps elements in sync as they move and change elevation. +/// - Keeps shadows consistent throughout and across applications. +/// +public partial class ThemeShadow : Shadow { /// - /// A ThemeShadow is a preconfigured shadow effect that can be applied to any XAML element to draw shadows appropriately based on x,y,z coordinates. - /// ThemeShadow also automatically adjusts for other environmental specifications. - /// - Adapts to changes in lighting, user theme, app environment, and shell. - /// - Shadows elements automatically based on their elevation. - /// - Keeps elements in sync as they move and change elevation. - /// - Keeps shadows consistent throughout and across applications. + /// Initializes a new instance of the ThemeShadow class. /// - public partial class ThemeShadow : Shadow + public ThemeShadow() { - /// - /// Initializes a new instance of the ThemeShadow class. - /// - public ThemeShadow() - { - } - - /// - /// Gets a collection of UI elements that this ThemeShadow is cast on. - /// - public UIElementWeakCollection Receivers { get; } = new UIElementWeakCollection(); } + + /// + /// Gets a collection of UI elements that this ThemeShadow is cast on. + /// + public UIElementWeakCollection Receivers { get; } = new UIElementWeakCollection(); + + // Lifted Xaml had an old projected shadow code path that we're keeping around (disabled) as insurance. All shadows + // are going through the drop shadow code path, hence we just return true here. + internal static bool IsDropShadowMode => true; }