Fix window maximize bug for macOS

This commit is contained in:
chinboy
2025-08-10 22:55:46 +08:00
parent 38dd46baa4
commit dddd978b37
11 changed files with 76 additions and 36 deletions
@@ -703,6 +703,7 @@ namespace AtomUI.Theme.Styling
public static readonly TokenResourceKey InnerMinMargin = new TokenResourceKey("ToggleSwitch.InnerMinMargin");
public static readonly TokenResourceKey InnerMinMarginSM = new TokenResourceKey("ToggleSwitch.InnerMinMarginSM");
public static readonly TokenResourceKey LoadingAnimationDuration = new TokenResourceKey("ToggleSwitch.LoadingAnimationDuration");
public static readonly TokenResourceKey OffStateLoadIndicatorColor = new TokenResourceKey("ToggleSwitch.OffStateLoadIndicatorColor");
public static readonly TokenResourceKey SwitchColor = new TokenResourceKey("ToggleSwitch.SwitchColor");
public static readonly TokenResourceKey SwitchDisabledOpacity = new TokenResourceKey("ToggleSwitch.SwitchDisabledOpacity");
public static readonly TokenResourceKey TrackHeight = new TokenResourceKey("ToggleSwitch.TrackHeight");
@@ -37,6 +37,7 @@
Name="{x:Static atom:AddOnDecoratedBoxThemeConstants.RightAddOnPart}"
Grid.Column="2"
Focusable="True"
IsEnabled="{TemplateBinding IsEnabled}"
Icon="{atom:IconProvider SearchOutlined}"
BackgroundSizing="OuterBorderEdge"
Content="{TemplateBinding SearchButtonText}"
@@ -24,16 +24,16 @@
<Setter Property="Foreground" Value="{DynamicResource {x:Static atom:ListBoxTokenKey.ItemColor}}" />
<Setter Property="Background" Value="{DynamicResource {x:Static atom:ListBoxTokenKey.ItemBgColor}}" />
<Style Selector="^:selected">
<Setter Property="Foreground" Value="{DynamicResource {x:Static atom:ListBoxTokenKey.ItemSelectedColor}}" />
<Setter Property="Background" Value="{DynamicResource {x:Static atom:ListBoxTokenKey.ItemSelectedBgColor}}" />
</Style>
<Style Selector="^[DisabledItemHoverEffect=False]:pointerover">
<Setter Property="Foreground" Value="{DynamicResource {x:Static atom:ListBoxTokenKey.ItemHoverColor}}" />
<Setter Property="Background" Value="{DynamicResource {x:Static atom:ListBoxTokenKey.ItemHoverBgColor}}" />
</Style>
<Style Selector="^:selected">
<Setter Property="Foreground" Value="{DynamicResource {x:Static atom:ListBoxTokenKey.ItemSelectedColor}}" />
<Setter Property="Background" Value="{DynamicResource {x:Static atom:ListBoxTokenKey.ItemSelectedBgColor}}" />
</Style>
<Style Selector="^[SizeType=Large]">
<Setter Property="CornerRadius" Value="{DynamicResource {x:Static atom:SharedTokenKey.BorderRadius}}" />
<Setter Property="MinHeight" Value="{DynamicResource {x:Static atom:SharedTokenKey.ControlHeightLG}}" />
+5 -1
View File
@@ -313,7 +313,11 @@ internal class PopupBuddyLayer : SceneLayer, IShadowAwareLayer
public void RunOpenMotion(Action? aboutToStart = null, Action? completedAction = null)
{
Debug.Assert(MotionActor != null);
if (MotionActor == null)
{
completedAction?.Invoke();
return;
}
var motion = OpenMotion ?? new ZoomBigInMotion();
if (MotionDuration != TimeSpan.Zero)
{
+22 -23
View File
@@ -17,19 +17,18 @@ using Avalonia.VisualTree;
namespace AtomUI.Controls;
internal class SwitchKnob : Control,
IResourceBindingManager
internal class SwitchKnob : Control, IResourceBindingManager
{
#region 公共属性定义
public static readonly StyledProperty<bool> IsCheckedStateProperty
= AvaloniaProperty.Register<SwitchKnob, bool>(nameof(IsCheckedState));
public static readonly StyledProperty<bool> IsCheckedStateProperty =
AvaloniaProperty.Register<SwitchKnob, bool>(nameof(IsCheckedState));
public static readonly StyledProperty<IBrush?> KnobBackgroundColorProperty
= AvaloniaProperty.Register<SwitchKnob, IBrush?>(nameof(KnobBackgroundColor));
public static readonly StyledProperty<IBrush?> KnobBackgroundColorProperty =
AvaloniaProperty.Register<SwitchKnob, IBrush?>(nameof(KnobBackgroundColor));
public static readonly StyledProperty<BoxShadow> KnobBoxShadowProperty
= AvaloniaProperty.Register<SwitchKnob, BoxShadow>(nameof(KnobBoxShadow));
public static readonly StyledProperty<BoxShadow> KnobBoxShadowProperty =
AvaloniaProperty.Register<SwitchKnob, BoxShadow>(nameof(KnobBoxShadow));
public IBrush? KnobBackgroundColor
{
@@ -53,26 +52,26 @@ internal class SwitchKnob : Control,
#region 内部属性定义
internal static readonly StyledProperty<int> RotationProperty
= AvaloniaProperty.Register<SwitchKnob, int>(nameof(Rotation));
internal static readonly StyledProperty<int> RotationProperty =
AvaloniaProperty.Register<SwitchKnob, int>(nameof(Rotation));
internal static readonly StyledProperty<IBrush?> LoadIndicatorBrushProperty
= AvaloniaProperty.Register<SwitchKnob, IBrush?>(nameof(LoadIndicatorBrush));
internal static readonly StyledProperty<IBrush?> LoadIndicatorBrushProperty =
AvaloniaProperty.Register<SwitchKnob, IBrush?>(nameof(LoadIndicatorBrush));
internal static readonly StyledProperty<Size> KnobSizeProperty
= AvaloniaProperty.Register<SwitchKnob, Size>(nameof(KnobSize));
internal static readonly StyledProperty<Size> KnobSizeProperty =
AvaloniaProperty.Register<SwitchKnob, Size>(nameof(KnobSize));
internal static readonly StyledProperty<double> KnobRenderWidthProperty
= AvaloniaProperty.Register<SwitchKnob, double>(nameof(KnobRenderWidth));
internal static readonly StyledProperty<double> KnobRenderWidthProperty =
AvaloniaProperty.Register<SwitchKnob, double>(nameof(KnobRenderWidth));
internal static readonly StyledProperty<bool> IsMotionEnabledProperty
= MotionAwareControlProperty.IsMotionEnabledProperty.AddOwner<SwitchKnob>();
internal static readonly StyledProperty<bool> IsMotionEnabledProperty =
MotionAwareControlProperty.IsMotionEnabledProperty.AddOwner<SwitchKnob>();
internal static readonly StyledProperty<TimeSpan> LoadingAnimationDurationProperty
= AvaloniaProperty.Register<SwitchKnob, TimeSpan>(nameof(LoadingAnimationDuration));
internal static readonly StyledProperty<TimeSpan> LoadingAnimationDurationProperty =
AvaloniaProperty.Register<SwitchKnob, TimeSpan>(nameof(LoadingAnimationDuration));
internal static readonly DirectProperty<SwitchKnob, double> LoadingBgOpacityTokenProperty
= AvaloniaProperty.RegisterDirect<SwitchKnob, double>(nameof(LoadingBgOpacity),
internal static readonly DirectProperty<SwitchKnob, double> LoadingBgOpacityTokenProperty =
AvaloniaProperty.RegisterDirect<SwitchKnob, double>(nameof(LoadingBgOpacity),
o => o.LoadingBgOpacity,
(o, v) => o.LoadingBgOpacity = v);
@@ -134,7 +133,7 @@ internal class SwitchKnob : Control,
static SwitchKnob()
{
AffectsRender<SwitchKnob>(
RotationProperty, KnobRenderWidthProperty);
RotationProperty, KnobRenderWidthProperty, LoadIndicatorBrushProperty);
AffectsMeasure<SwitchKnob>(KnobSizeProperty);
}
@@ -93,7 +93,7 @@
<Setter Property="KnobBoxShadow"
Value="{DynamicResource {x:Static atom:ToggleSwitchTokenKey.HandleShadow}}" />
<Setter Property="LoadIndicatorBrush"
Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorTextQuaternary}}" />
Value="{DynamicResource {x:Static atom:ToggleSwitchTokenKey.OffStateLoadIndicatorColor}}" />
<Style Selector="^[IsCheckedState=True]">
<Setter Property="LoadIndicatorBrush"
Value="{DynamicResource {x:Static atom:ToggleSwitchTokenKey.SwitchColor}}" />
@@ -1,3 +1,4 @@
using AtomUI.Media;
using AtomUI.Theme.TokenSystem;
using Avalonia;
using Avalonia.Media;
@@ -89,12 +90,35 @@ internal class ToggleSwitchToken : AbstractControlDesignToken
/// </summary>
public double IconSizeSM { get; set; }
/// <summary>
/// 开关的颜色
/// </summary>
public Color SwitchColor { get; set; }
/// <summary>
/// 开源禁用状态的透明度
/// </summary>
public double SwitchDisabledOpacity { get; set; }
/// <summary>
/// 开关空白区域的字体大小,正常尺寸
/// </summary>
public double ExtraInfoFontSize { get; set; }
/// <summary>
/// 开关空白区域的字体大小,小尺寸
/// </summary>
public double ExtraInfoFontSizeSM { get; set; }
/// <summary>
/// 加载动画的周期时长
/// </summary>
public TimeSpan LoadingAnimationDuration { get; set; }
/// <summary>
/// 在关状态下的加载指示器的颜色
/// </summary>
public Color OffStateLoadIndicatorColor { get; set; }
protected internal override void CalculateFromAlias()
{
@@ -137,8 +161,9 @@ internal class ToggleSwitchToken : AbstractControlDesignToken
Color = Color.FromArgb((int)(255 * 0.2), 0, 35, 11)
};
IconSize = TrackHeightSM;
IconSizeSM = TrackHeightSM - SharedToken.UniformlyPaddingXXS;
LoadingAnimationDuration = TimeSpan.FromMilliseconds(1200); // 毫秒
IconSize = TrackHeightSM;
IconSizeSM = TrackHeightSM - SharedToken.UniformlyPaddingXXS;
LoadingAnimationDuration = TimeSpan.FromMilliseconds(1200); // 毫秒
OffStateLoadIndicatorColor = ColorUtils.FromRgbF(0.4,0.0, 0.0, 0.0);
}
}
@@ -105,6 +105,7 @@ public class BaseTabControl : AvaloniaTabControl,
{
AutoScrollToSelectedItemProperty.OverrideDefaultValue<BaseTabControl>(false);
ItemsPanelProperty.OverrideDefaultValue<BaseTabControl>(DefaultPanel);
AffectsRender<BaseTabControl>(BorderBrushProperty);
}
public BaseTabControl()
@@ -84,7 +84,7 @@ public abstract class BaseTabStrip : AvaloniaTabStrip,
{
ItemsPanelProperty.OverrideDefaultValue<BaseTabStrip>(DefaultPanel);
AutoScrollToSelectedItemProperty.OverrideDefaultValue<BaseTabStrip>(false);
AffectsRender<BaseTabStrip>(TabStripPlacementProperty);
AffectsRender<BaseTabStrip>(TabStripPlacementProperty, BorderBrushProperty);
}
public BaseTabStrip()
@@ -17,7 +17,9 @@
IsVisible="{Binding $parent[atom:Window].IsResizeEnabled}"/>
</VisualLayerManager.ChromeOverlayLayer>
<Border Name="ContentFrame"
CornerRadius="{TemplateBinding CornerRadius}" ClipToBounds="True">
CornerRadius="{TemplateBinding CornerRadius}"
ClipToBounds="True"
Cursor="Arrow">
<DockPanel LastChildFill="True">
<Border Padding="{TemplateBinding MacOSTitleBarMargin}" DockPanel.Dock="Top">
<atom:TitleBar Name="{x:Static atom:WindowThemeConstants.TitleBarPart}"
@@ -97,11 +99,18 @@
<Setter Property="IsFullScreenCaptionButtonEnabled" Value="False"/>
<Setter Property="IsCloseCaptionButtonEnabled" Value="False"/>
</Style>
<Style Selector="^:not(^[OperationSystemType=macOS])">
<Setter Property="IsMaximizeCaptionButtonEnabled" Value="True"/>
<Setter Property="IsMinimizeCaptionButtonEnabled" Value="True"/>
<Setter Property="IsCloseCaptionButtonEnabled" Value="True"/>
<Setter Property="IsFullScreenCaptionButtonEnabled" Value="True"/>
</Style>
<Style Selector="^:not(^[OperationSystemType=Linux])">
<Setter Property="IsResizeEnabled" Value="False"/>
<Setter Property="CornerRadius" Value="0" />
</Style>
</ControlTheme>
</ResourceDictionary>
+1 -1
View File
@@ -311,7 +311,7 @@ public class Window : AvaloniaWindow, IOperationSystemAware, IDisposable
return;
}
if (windowState == WindowState.Normal && IsMaximizeCaptionButtonEnabled)
if (windowState == WindowState.Normal && (OperationSystemType == OperationSystemType.macOS || IsMaximizeCaptionButtonEnabled))
{
WindowState = WindowState.Maximized;
}