Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ElasticWrapPanel control #261

Merged
merged 16 commits into from
Jun 15, 2024
Empty file.
319 changes: 319 additions & 0 deletions demo/Ursa.Demo/Pages/ElasticWrapPanelDemo.axaml

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions demo/Ursa.Demo/Pages/ElasticWrapPanelDemo.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Avalonia.Controls;
using Ursa.Demo.ViewModels;

namespace Ursa.Demo.Pages;

public partial class ElasticWrapPanelDemo : UserControl
{
public ElasticWrapPanelDemo()
{
InitializeComponent();
DataContext = new ElasticWrapPanelDemoViewModel();
}
}
54 changes: 54 additions & 0 deletions demo/Ursa.Demo/ViewModels/ElasticWrapPanelDemoViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Avalonia.Controls.Primitives;
using Avalonia.Layout;
using CommunityToolkit.Mvvm.ComponentModel;

namespace Ursa.Demo.ViewModels;

public partial class ElasticWrapPanelDemoViewModel : ObservableObject
{
[ObservableProperty] private Orientation _selectedOrientation = Orientation.Horizontal;
[ObservableProperty] private ScrollBarVisibility _horizontalVisibility = ScrollBarVisibility.Auto;
[ObservableProperty] private ScrollBarVisibility _verticalVisibility = ScrollBarVisibility.Auto;

[ObservableProperty] private bool _isFillHorizontal;
[ObservableProperty] private bool _isFillVertical;
[ObservableProperty] private double _itemWidth = 40d;
[ObservableProperty] private double _itemHeight = 40d;

[ObservableProperty] private bool _autoWidth = true;
[ObservableProperty] private bool _autoHeight = true;
[ObservableProperty] private double _itemSelfWidth = double.NaN;
[ObservableProperty] private double _itemSelfHeight = double.NaN;

[ObservableProperty] private HorizontalAlignment _cmbHAlign = HorizontalAlignment.Left;
[ObservableProperty] private VerticalAlignment _cmbVAlign = VerticalAlignment.Stretch;

private double _oldItemSelfWidth;
private double _oldItemSelfHeight;

partial void OnAutoWidthChanged(bool value)
{
if (value)
{
_oldItemSelfWidth = ItemSelfWidth;
ItemSelfWidth = double.NaN;
}
else
{
ItemSelfWidth = _oldItemSelfWidth;
}
}

partial void OnAutoHeightChanged(bool value)
{
if (value)
{
_oldItemSelfHeight = ItemSelfHeight;
ItemSelfHeight = double.NaN;
}
else
{
ItemSelfHeight = _oldItemSelfHeight;
}
}
}
1 change: 1 addition & 0 deletions demo/Ursa.Demo/ViewModels/MainViewViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ private void OnNavigation(MainViewViewModel vm, string s)
MenuKeys.MenuKeyDisableContainer => new DisableContainerDemoViewModel(),
MenuKeys.MenuKeyDrawer => new DrawerDemoViewModel(),
MenuKeys.MenuKeyDualBadge => new DualBadgeDemoViewModel(),
MenuKeys.MenuKeyElasticWrapPanel => new ElasticWrapPanelDemoViewModel(),
MenuKeys.MenuKeyEnumSelector => new EnumSelectorDemoViewModel(),
MenuKeys.MenuKeyForm => new FormDemoViewModel(),
MenuKeys.MenuKeyImageViewer => new ImageViewerDemoViewModel(),
Expand Down
2 changes: 2 additions & 0 deletions demo/Ursa.Demo/ViewModels/MenuViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public MenuViewModel()
new() { MenuHeader = "Divider", Key = MenuKeys.MenuKeyDivider },
new() { MenuHeader = "Drawer", Key = MenuKeys.MenuKeyDrawer },
new() { MenuHeader = "DualBadge", Key = MenuKeys.MenuKeyDualBadge },
new() { MenuHeader = "ElasticWrapPanel", Key = MenuKeys.MenuKeyElasticWrapPanel },
new() { MenuHeader = "Enum Selector", Key = MenuKeys.MenuKeyEnumSelector },
new() { MenuHeader = "Form", Key = MenuKeys.MenuKeyForm },
new() { MenuHeader = "Icon Button", Key = MenuKeys.MenuKeyIconButton },
Expand Down Expand Up @@ -68,6 +69,7 @@ public static class MenuKeys
public const string MenuKeyDisableContainer = "DisableContainer";
public const string MenuKeyDrawer = "Drawer";
public const string MenuKeyDualBadge = "DualBadge";
public const string MenuKeyElasticWrapPanel = "ElasticWrapPanel";
public const string MenuKeyEnumSelector = "EnumSelector";
public const string MenuKeyForm = "Form";
public const string MenuKeyImageViewer = "ImageViewer";
Expand Down
3 changes: 3 additions & 0 deletions src/Ursa.Themes.Semi/Controls/ElasticWrapPanel.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
</ResourceDictionary>
1 change: 1 addition & 0 deletions src/Ursa.Themes.Semi/Controls/_index.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<ResourceInclude Source="Divider.axaml" />
<ResourceInclude Source="Drawer.axaml" />
<ResourceInclude Source="DualBadge.axaml" />
<ResourceInclude Source="ElasticWrapPanel.axaml" />
<ResourceInclude Source="EnumSelector.axaml" />
<ResourceInclude Source="Form.axaml" />
<ResourceInclude Source="IconButton.axaml" />
Expand Down
Loading