Skip to content

Commit

Permalink
Merge pull request #261 from irihitech/ElasticWrapPanel
Browse files Browse the repository at this point in the history
Add ElasticWrapPanel control
  • Loading branch information
rabbitism authored Jun 15, 2024
2 parents febbf22 + 33748cf commit fb11370
Show file tree
Hide file tree
Showing 9 changed files with 874 additions and 0 deletions.
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 @@ -69,6 +70,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

0 comments on commit fb11370

Please sign in to comment.