Skip to content

Commit

Permalink
feat: Update AppBarSeparator to winui3/release/1.6.4
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Jan 30, 2025
1 parent 0ca970c commit 90c983d
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 149 deletions.
67 changes: 0 additions & 67 deletions src/Uno.UI/UI/Xaml/Controls/AppBar/AppBarSeparator.Partial.cs

This file was deleted.

159 changes: 78 additions & 81 deletions src/Uno.UI/UI/Xaml/Controls/AppBar/AppBarSeparator.Properties.cs
Original file line number Diff line number Diff line change
@@ -1,95 +1,92 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
// MUX Reference dxaml\xcp\dxaml\lib\AppBarSeparator_Partial.cpp, tag winui3/release/1.6.4, commit 262a901e09

namespace Microsoft.UI.Xaml.Controls
namespace Microsoft.UI.Xaml.Controls;

partial class AppBarSeparator
{
partial class AppBarSeparator
/// <summary>
/// Gets or sets the order in which this item is moved to the CommandBar overflow menu.
/// </summary>
public int DynamicOverflowOrder
{
#region IsCompat

public bool IsCompact
{
get => (bool)this.GetValue(IsCompactProperty);
set => this.SetValue(IsCompactProperty, value);
}
get => (int)GetValue(DynamicOverflowOrderProperty);
set => SetValue(DynamicOverflowOrderProperty, value);
}

public static DependencyProperty IsCompactProperty { get; } =
/// <summary>
/// Identifies the DynamicOverflowOrder dependency property.
/// </summary>
public static DependencyProperty DynamicOverflowOrderProperty { get; } =
DependencyProperty.Register(
"IsCompact",
typeof(bool),
nameof(DynamicOverflowOrder),
typeof(int),
typeof(AppBarSeparator),
new FrameworkPropertyMetadata(default(bool))
);

#endregion

#region DynamicOverflowOrder

public int DynamicOverflowOrder
{
get => (int)this.GetValue(DynamicOverflowOrderProperty);
set => this.SetValue(DynamicOverflowOrderProperty, value);
}
new FrameworkPropertyMetadata(default(int)));

public static DependencyProperty DynamicOverflowOrderProperty { get; } =
DependencyProperty.Register(
"DynamicOverflowOrder",
typeof(int),
typeof(AppBarSeparator),
new FrameworkPropertyMetadata(default(int))
);

#endregion

#region IsInOverflow

public bool IsInOverflow
{
get => CommandBar.IsCommandBarElementInOverflow(this);
internal set => this.SetValue(IsInOverflowProperty, value);
}

bool ICommandBarElement3.IsInOverflow
{
get => IsInOverflow;
set => IsInOverflow = value;
}

public static DependencyProperty IsInOverflowProperty { get; } =
DependencyProperty.Register(
"IsInOverflow",
typeof(bool),
typeof(AppBarSeparator),
new FrameworkPropertyMetadata(default(bool))
);

#endregion
/// <summary>
/// Gets or sets a value that indicates whether the separator is shown with reduced padding.
/// </summary>
public bool IsCompact
{
get => (bool)GetValue(IsCompactProperty);
set => SetValue(IsCompactProperty, value);
}

#region UseOverflowStyle
/// <summary>
/// Identifies the IsCompact dependency property.
/// </summary>
public static DependencyProperty IsCompactProperty { get; } =
DependencyProperty.Register(
nameof(IsCompact),
typeof(bool),
typeof(AppBarSeparator),
new FrameworkPropertyMetadata(default(bool))
);

/// <summary>
/// Gets a value that indicates whether this item is in the overflow menu.
/// </summary>
public bool IsInOverflow
{
get => CommandBar.IsCommandBarElementInOverflow(this);
private set => SetValue(IsInOverflowProperty, value);
}

internal bool UseOverflowStyle
{
get => (bool)this.GetValue(UseOverflowStyleProperty);
set => this.SetValue(UseOverflowStyleProperty, value);
}
/// <summary>
/// Identifies the IsInOverflow dependency property.
/// </summary>
public static DependencyProperty IsInOverflowProperty { get; } =
DependencyProperty.Register(
nameof(IsInOverflow),
typeof(bool),
typeof(AppBarSeparator),
new FrameworkPropertyMetadata(default(bool)));

bool ICommandBarOverflowElement.UseOverflowStyle
{
get => UseOverflowStyle;
set => UseOverflowStyle = value;
}
bool ICommandBarElement3.IsInOverflow
{
get => IsInOverflow;
set => IsInOverflow = value;
}

internal static DependencyProperty UseOverflowStyleProperty { get; } =
DependencyProperty.Register(
nameof(UseOverflowStyle),
typeof(bool),
typeof(AppBarSeparator),
new FrameworkPropertyMetadata(default(bool))
);
internal bool UseOverflowStyle
{
get => (bool)GetValue(UseOverflowStyleProperty);
set => SetValue(UseOverflowStyleProperty, value);
}

#endregion
bool ICommandBarOverflowElement.UseOverflowStyle
{
get => UseOverflowStyle;
set => UseOverflowStyle = value;
}

internal static DependencyProperty UseOverflowStyleProperty { get; } =
DependencyProperty.Register(
nameof(UseOverflowStyle),
typeof(bool),
typeof(AppBarSeparator),
new FrameworkPropertyMetadata(default(bool))
);
}
15 changes: 15 additions & 0 deletions src/Uno.UI/UI/Xaml/Controls/AppBar/AppBarSeparator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Microsoft.UI.Xaml.Controls;

/// <summary>
/// Represents a line that separates items in an AppBar or CommandBar.
/// </summary>
public partial class AppBarSeparator : Control, ICommandBarElement, ICommandBarElement2, ICommandBarElement3, ICommandBarOverflowElement
{
/// <summary>
/// Initializes a new instance of the AppBarSeparator class.
/// </summary>
public AppBarSeparator()
{
DefaultStyleKey = typeof(AppBarSeparator);
}
}
57 changes: 57 additions & 0 deletions src/Uno.UI/UI/Xaml/Controls/AppBar/AppBarSeparator.partial.mux.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
// MUX Reference dxaml\xcp\dxaml\lib\AppBarSeparator_Partial.cpp, tag winui3/release/1.6.4, commit 262a901e09

#nullable enable

namespace Microsoft.UI.Xaml.Controls;

public partial class AppBarSeparator : Control, ICommandBarElement, ICommandBarElement2, ICommandBarElement3, ICommandBarOverflowElement
{
internal override void OnPropertyChanged2(DependencyPropertyChangedEventArgs args)
{
base.OnPropertyChanged2(args);

if (args.Property == IsCompactProperty ||
args.Property == UseOverflowStyleProperty)
{
UpdateVisualState();
}
}

// After template is applied, set the initial view state
// (FullSize or Compact) based on the value of our
// IsCompact property
protected override void OnApplyTemplate()
{
base.OnApplyTemplate();

UpdateVisualState();
}

// Sets the visual state to "Compact" or "FullSize" based on the value
// of our IsCompact property
private protected override void ChangeVisualState(bool useTransitions)
{
base.ChangeVisualState(useTransitions);

var useOverflowStyle = UseOverflowStyle;
var isCompact = IsCompact;

if (useOverflowStyle)
{
GoToState(useTransitions, "Overflow");
}
else if (isCompact)
{
GoToState(useTransitions, "Compact");
}
else
{
GoToState(useTransitions, "FullSize");
}
}

private protected override void OnVisibilityChanged() =>
CommandBar.OnCommandBarElementVisibilityChanged(this);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ namespace Microsoft.UI.Xaml.Controls;

public partial class AppBarToggleButton : ToggleButton, ICommandBarElement, ICommandBarElement2, ICommandBarElement3, ICommandBarOverflowElement, ICommandBarLabeledElement, IAppBarButtonHelpersProvider
{

DependencyProperty IAppBarButtonHelpersProvider.GetIsCompactDependencyProperty() => IsCompactProperty;

DependencyProperty IAppBarButtonHelpersProvider.GetUseOverflowStyleDependencyProperty() => UseOverflowStyleProperty;

DependencyProperty IAppBarButtonHelpersProvider.GetLabelPositionDependencyProperty() => LabelPositionProperty;

DependencyProperty IAppBarButtonHelpersProvider.GetLabelDependencyProperty() => LabelProperty;

DependencyProperty IAppBarButtonHelpersProvider.GetIconDependencyProperty() => IconProperty;

DependencyProperty IAppBarButtonHelpersProvider.GetKeyboardAcceleratorTextDependencyProperty() => KeyboardAcceleratorTextOverrideProperty;

/// <summary>
Expand Down

0 comments on commit 90c983d

Please sign in to comment.