Skip to content

Commit

Permalink
feat: Support for SelectorBar and SelectorBarItem
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed May 22, 2024
1 parent 9930fb3 commit 9068f91
Show file tree
Hide file tree
Showing 17 changed files with 646 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.UI.Xaml.Automation.Peers
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented]
#endif
public partial class SelectorBarItemAutomationPeer : global::Microsoft.UI.Xaml.Automation.Peers.ItemContainerAutomationPeer
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public SelectorBarItemAutomationPeer(global::Microsoft.UI.Xaml.Controls.SelectorBarItem owner) : base(owner)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.UI.Xaml.Controls
{
[global::Microsoft.UI.Xaml.Markup.ContentPropertyAttribute(Name = "Items")]
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented]
#endif
public partial class SelectorBar : global::Microsoft.UI.Xaml.Controls.Control
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Microsoft.UI.Xaml.Controls.SelectorBarItem SelectedItem
{
Expand All @@ -23,7 +22,7 @@ public partial class SelectorBar : global::Microsoft.UI.Xaml.Controls.Control
}
}
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::System.Collections.Generic.IList<global::Microsoft.UI.Xaml.Controls.SelectorBarItem> Items
{
Expand All @@ -33,23 +32,23 @@ public partial class SelectorBar : global::Microsoft.UI.Xaml.Controls.Control
}
}
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public static global::Microsoft.UI.Xaml.DependencyProperty ItemsProperty { get; } =
Microsoft.UI.Xaml.DependencyProperty.Register(
nameof(Items), typeof(global::System.Collections.Generic.IList<global::Microsoft.UI.Xaml.Controls.SelectorBarItem>),
typeof(global::Microsoft.UI.Xaml.Controls.SelectorBar),
new Microsoft.UI.Xaml.FrameworkPropertyMetadata(default(global::System.Collections.Generic.IList<global::Microsoft.UI.Xaml.Controls.SelectorBarItem>)));
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public static global::Microsoft.UI.Xaml.DependencyProperty SelectedItemProperty { get; } =
Microsoft.UI.Xaml.DependencyProperty.Register(
nameof(SelectedItem), typeof(global::Microsoft.UI.Xaml.Controls.SelectorBarItem),
typeof(global::Microsoft.UI.Xaml.Controls.SelectorBar),
new Microsoft.UI.Xaml.FrameworkPropertyMetadata(default(global::Microsoft.UI.Xaml.Controls.SelectorBarItem)));
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public SelectorBar() : base()
{
Expand All @@ -64,7 +63,7 @@ public SelectorBar() : base()
// Forced skipping of method Microsoft.UI.Xaml.Controls.SelectorBar.SelectionChanged.remove
// Forced skipping of method Microsoft.UI.Xaml.Controls.SelectorBar.ItemsProperty.get
// Forced skipping of method Microsoft.UI.Xaml.Controls.SelectorBar.SelectedItemProperty.get
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public event global::Windows.Foundation.TypedEventHandler<global::Microsoft.UI.Xaml.Controls.SelectorBar, global::Microsoft.UI.Xaml.Controls.SelectorBarSelectionChangedEventArgs> SelectionChanged
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.UI.Xaml.Controls
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented]
#endif
public partial class SelectorBarItem : global::Microsoft.UI.Xaml.Controls.ItemContainer
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public string Text
{
Expand All @@ -22,7 +22,7 @@ public string Text
}
}
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Microsoft.UI.Xaml.Controls.IconElement Icon
{
Expand All @@ -36,23 +36,23 @@ public string Text
}
}
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public static global::Microsoft.UI.Xaml.DependencyProperty IconProperty { get; } =
Microsoft.UI.Xaml.DependencyProperty.Register(
nameof(Icon), typeof(global::Microsoft.UI.Xaml.Controls.IconElement),
typeof(global::Microsoft.UI.Xaml.Controls.SelectorBarItem),
new Microsoft.UI.Xaml.FrameworkPropertyMetadata(default(global::Microsoft.UI.Xaml.Controls.IconElement)));
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public static global::Microsoft.UI.Xaml.DependencyProperty TextProperty { get; } =
Microsoft.UI.Xaml.DependencyProperty.Register(
nameof(Text), typeof(string),
typeof(global::Microsoft.UI.Xaml.Controls.SelectorBarItem),
new Microsoft.UI.Xaml.FrameworkPropertyMetadata(default(string)));
#endif
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public SelectorBarItem() : base()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.UI.Xaml.Controls
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented]
#endif
public partial class SelectorBarSelectionChangedEventArgs
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
internal SelectorBarSelectionChangedEventArgs()
{
}
Expand Down
6 changes: 6 additions & 0 deletions src/Uno.UI/Helpers/WinUI/CppWinRTHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ public static IDisposable RegisterXamlRootChanged(XamlRoot xamlRoot, TypedEventH
return Disposable.Create(() => xamlRoot.Changed -= handler);
}

public static IDisposable RegisterPropertyChanged(DependencyObject dependencyObject, DependencyProperty dependencyProperty, DependencyPropertyChangedCallback callback)
{
var token = dependencyObject.RegisterPropertyChangedCallback(dependencyProperty, callback);
return Disposable.Create(() => dependencyObject.UnregisterPropertyChangedCallback(dependencyProperty, token));
}

public static bool SetFocus(DependencyObject obj, FocusState focusState)
{
if (obj != null)
Expand Down
2 changes: 2 additions & 0 deletions src/Uno.UI/Helpers/WinUI/ResourceAccessor.ResourceKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ internal partial class ResourceAccessor
public const string SR_NumberBoxMinimumValueStatus = "NumberBoxMinimumValueStatus";
public const string SR_ItemContainerDefaultControlName = "ItemContainerDefaultControlName";

public const string SR_SelectorBarItemDefaultControlName = "SelectorBarItemDefaultControlName";

public const string SR_InfoBarCloseButtonName = "InfoBarCloseButtonName";
public const string SR_InfoBarOpenedNotification = "InfoBarOpenedNotification";
public const string SR_InfoBarClosedNotification = "InfoBarClosedNotification";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
// MUX Reference controls\dev\Generated\SelectorBar.properties.cpp, tag winui3/release/1.5.2, commit b91b3ce6f25c587a9e18c4e122f348f51331f18b

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Foundation;

namespace Microsoft.UI.Xaml.Controls;

partial class SelectorBar
{
/// <summary>
/// Gets the collection of SelectorBarItem instances used to generate the content of the SelectorBar control.
/// </summary>
public IList<SelectorBarItem> Items => (IList<SelectorBarItem>)GetValue(ItemsProperty);

/// <summary>
/// Identifies the Items dependency property.
/// </summary>
public static DependencyProperty ItemsProperty { get; } =
DependencyProperty.Register(
nameof(Items),
typeof(IList<SelectorBarItem>),
typeof(SelectorBar),
new FrameworkPropertyMetadata(default(IList<SelectorBarItem>), OnPropertyChanged));

/// <summary>
/// Gets or sets the currently selected item.
/// </summary>
public SelectorBarItem SelectedItem
{
get => (SelectorBarItem)GetValue(SelectedItemProperty);
set => SetValue(SelectedItemProperty, value);
}

/// <summary>
/// Identifies the SelectedItem dependency property.
/// </summary>
public static DependencyProperty SelectedItemProperty { get; } =
DependencyProperty.Register(
nameof(SelectedItem),
typeof(SelectorBarItem),
typeof(SelectorBar),
new FrameworkPropertyMetadata(default(SelectorBarItem), OnPropertyChanged));

/// <summary>
/// Occurs when the SelectorBar selection changes; that is, when the SelectedItem property has changed.
/// </summary>
public event TypedEventHandler<SelectorBar, SelectorBarSelectionChangedEventArgs> SelectionChanged;

private static void OnPropertyChanged(
DependencyObject sender,
DependencyPropertyChangedEventArgs args)
{
var owner = (SelectorBar)sender;
owner.OnPropertyChanged(args);
}
}
10 changes: 10 additions & 0 deletions src/Uno.UI/Microsoft/UI/Xaml/Controls/SelectorBar/SelectorBar.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#nullable enable

using Microsoft.UI.Xaml.Markup;

namespace Microsoft.UI.Xaml.Controls;

[ContentProperty(Name = nameof(Items))]
public partial class SelectorBar : Control
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
// MUX Reference controls\dev\SelectorBar\SelectorBar.h, tag winui3/release/1.5.2, commit b91b3ce6f25c587a9e18c4e122f348f51331f18b

#nullable enable

using Uno.Disposables;

namespace Microsoft.UI.Xaml.Controls;

partial class SelectorBar
{
private ItemsView? _itemsView;

private readonly SerialDisposable _loadedRevoker = new();

private readonly SerialDisposable _itemsViewSelectedItemPropertyChangedRevoker = new();

private const string s_itemsViewPartName = "PART_ItemsView";
}
Loading

0 comments on commit 9068f91

Please sign in to comment.