From 2682e08095270f0e8344c7c5a7e41bcbc5766630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20S=CC=8Colte=CC=81s?= Date: Tue, 12 Nov 2024 15:16:06 +0100 Subject: [PATCH 1/6] Move properties to IDockable --- src/Dock.Model.Avalonia/Core/DockBase.cs | 50 +------------------ src/Dock.Model.Avalonia/Core/DockableBase.cs | 48 ++++++++++++++++++ src/Dock.Model.Mvvm/Core/DockBase.cs | 27 ---------- src/Dock.Model.Mvvm/Core/DockableBase.cs | 27 ++++++++++ src/Dock.Model.ReactiveUI/Core/DockBase.cs | 27 ---------- .../Core/DockableBase.cs | 27 ++++++++++ src/Dock.Model/Core/IDock.cs | 15 ------ src/Dock.Model/Core/IDockable.cs | 15 ++++++ 8 files changed, 118 insertions(+), 118 deletions(-) diff --git a/src/Dock.Model.Avalonia/Core/DockBase.cs b/src/Dock.Model.Avalonia/Core/DockBase.cs index d08ee14e4..5da5a7757 100644 --- a/src/Dock.Model.Avalonia/Core/DockBase.cs +++ b/src/Dock.Model.Avalonia/Core/DockBase.cs @@ -51,13 +51,7 @@ public abstract class DockBase : DockableBase, IDock AvaloniaProperty.RegisterDirect(nameof(FocusedDockable), o => o.FocusedDockable, (o, v) => o.FocusedDockable = v); /// - /// Defines the property. - /// - public static readonly DirectProperty ProportionProperty = - AvaloniaProperty.RegisterDirect(nameof(Proportion), o => o.Proportion, (o, v) => o.Proportion = v, double.NaN); - - /// - /// Defines the property. + /// Defines the property. /// public static readonly DirectProperty DockProperty = AvaloniaProperty.RegisterDirect(nameof(Dock), o => o.Dock, (o, v) => o.Dock = v); @@ -68,24 +62,12 @@ public abstract class DockBase : DockableBase, IDock public static readonly DirectProperty IsActiveProperty = AvaloniaProperty.RegisterDirect(nameof(IsActive), o => o.IsActive, (o, v) => o.IsActive = v); - /// - /// Defines the property. - /// - public static readonly DirectProperty IsEmptyProperty = - AvaloniaProperty.RegisterDirect(nameof(IsEmpty), o => o.IsEmpty, (o, v) => o.IsEmpty = v); - /// /// Defines the property. /// public static readonly DirectProperty OpenedDockablesCountProperty = AvaloniaProperty.RegisterDirect(nameof(OpenedDockablesCount), o => o.OpenedDockablesCount, (o, v) => o.OpenedDockablesCount = v); - /// - /// Defines the property. - /// - public static readonly DirectProperty IsCollapsableProperty = - AvaloniaProperty.RegisterDirect(nameof(IsCollapsable), o => o.IsCollapsable, (o, v) => o.IsCollapsable = v, true); - /// /// Defines the property. /// @@ -103,11 +85,8 @@ public abstract class DockBase : DockableBase, IDock private IDockable? _activeDockable; private IDockable? _defaultDockable; private IDockable? _focusedDockable; - private double _proportion = double.NaN; private DockMode _dock = DockMode.Center; private bool _isActive; - private bool _isEmpty; - private bool _isCollapsable = true; private bool _canGoBack; private bool _canGoForward; private int _openedDockablesCount; @@ -175,15 +154,6 @@ public IDockable? FocusedDockable } } - /// - [DataMember(IsRequired = false, EmitDefaultValue = true)] - [JsonPropertyName("Proportion")] - public double Proportion - { - get => _proportion; - set => SetAndRaise(ProportionProperty, ref _proportion, value); - } - /// [DataMember(IsRequired = false, EmitDefaultValue = true)] [JsonPropertyName("Dock")] @@ -202,15 +172,6 @@ public bool IsActive set => SetAndRaise(IsActiveProperty, ref _isActive, value); } - /// - [DataMember(IsRequired = false, EmitDefaultValue = true)] - [JsonPropertyName("IsEmpty")] - public bool IsEmpty - { - get => _isEmpty; - set => SetAndRaise(IsEmptyProperty, ref _isEmpty, value); - } - /// [DataMember(IsRequired = false, EmitDefaultValue = true)] [JsonIgnore] @@ -220,15 +181,6 @@ public int OpenedDockablesCount set => SetAndRaise(OpenedDockablesCountProperty, ref _openedDockablesCount, value); } - /// - [DataMember(IsRequired = false, EmitDefaultValue = true)] - [JsonPropertyName("IsCollapsable")] - public bool IsCollapsable - { - get => _isCollapsable; - set => SetAndRaise(IsCollapsableProperty, ref _isCollapsable, value); - } - /// [IgnoreDataMember] [JsonIgnore] diff --git a/src/Dock.Model.Avalonia/Core/DockableBase.cs b/src/Dock.Model.Avalonia/Core/DockableBase.cs index 2e30c004a..74ebd58b8 100644 --- a/src/Dock.Model.Avalonia/Core/DockableBase.cs +++ b/src/Dock.Model.Avalonia/Core/DockableBase.cs @@ -60,6 +60,24 @@ public abstract class DockableBase : StyledElement, IDockable public static readonly DirectProperty FactoryProperty = AvaloniaProperty.RegisterDirect(nameof(Factory), o => o.Factory, (o, v) => o.Factory = v); + /// + /// Defines the property. + /// + public static readonly DirectProperty IsEmptyProperty = + AvaloniaProperty.RegisterDirect(nameof(IsEmpty), o => o.IsEmpty, (o, v) => o.IsEmpty = v); + + /// + /// Defines the property. + /// + public static readonly DirectProperty IsCollapsableProperty = + AvaloniaProperty.RegisterDirect(nameof(IsCollapsable), o => o.IsCollapsable, (o, v) => o.IsCollapsable = v, true); + + /// + /// Defines the property. + /// + public static readonly DirectProperty ProportionProperty = + AvaloniaProperty.RegisterDirect(nameof(Proportion), o => o.Proportion, (o, v) => o.Proportion = v, double.NaN); + /// /// Defines the property. /// @@ -85,6 +103,9 @@ public abstract class DockableBase : StyledElement, IDockable private IDockable? _owner; private IDockable? _originalOwner; private IFactory? _factory; + private bool _isEmpty; + private bool _isCollapsable = true; + private double _proportion = double.NaN; private bool _canClose = true; private bool _canPin = true; private bool _canFloat = true; @@ -153,6 +174,33 @@ public IFactory? Factory set => SetAndRaise(FactoryProperty, ref _factory, value); } + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + [JsonPropertyName("IsEmpty")] + public bool IsEmpty + { + get => _isEmpty; + set => SetAndRaise(IsEmptyProperty, ref _isEmpty, value); + } + + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + [JsonPropertyName("IsCollapsable")] + public bool IsCollapsable + { + get => _isCollapsable; + set => SetAndRaise(IsCollapsableProperty, ref _isCollapsable, value); + } + + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + [JsonPropertyName("Proportion")] + public double Proportion + { + get => _proportion; + set => SetAndRaise(ProportionProperty, ref _proportion, value); + } + /// [DataMember(IsRequired = false, EmitDefaultValue = true)] [JsonPropertyName("CanClose")] diff --git a/src/Dock.Model.Mvvm/Core/DockBase.cs b/src/Dock.Model.Mvvm/Core/DockBase.cs index e14d9684c..e93cb39ef 100644 --- a/src/Dock.Model.Mvvm/Core/DockBase.cs +++ b/src/Dock.Model.Mvvm/Core/DockBase.cs @@ -18,12 +18,9 @@ public abstract class DockBase : DockableBase, IDock private IDockable? _activeDockable; private IDockable? _defaultDockable; private IDockable? _focusedDockable; - private double _proportion = double.NaN; private DockMode _dock = DockMode.Center; - private bool _isCollapsable = true; private int _openedDockablesCount = 0; private bool _isActive; - private bool _isEmpty; /// /// Initializes new instance of the class. @@ -79,14 +76,6 @@ public IDockable? FocusedDockable } } - /// - [DataMember(IsRequired = false, EmitDefaultValue = true)] - public double Proportion - { - get => _proportion; - set => SetProperty(ref _proportion, value); - } - /// [DataMember(IsRequired = false, EmitDefaultValue = true)] public DockMode Dock @@ -103,22 +92,6 @@ public bool IsActive set => SetProperty(ref _isActive, value); } - /// - [DataMember(IsRequired = false, EmitDefaultValue = true)] - public bool IsEmpty - { - get => _isEmpty; - set => SetProperty(ref _isEmpty, value); - } - - /// - [DataMember(IsRequired = false, EmitDefaultValue = true)] - public bool IsCollapsable - { - get => _isCollapsable; - set => SetProperty(ref _isCollapsable, value); - } - /// [DataMember(IsRequired = false, EmitDefaultValue = true)] public int OpenedDockablesCount diff --git a/src/Dock.Model.Mvvm/Core/DockableBase.cs b/src/Dock.Model.Mvvm/Core/DockableBase.cs index 2ac85521f..afa54d28f 100644 --- a/src/Dock.Model.Mvvm/Core/DockableBase.cs +++ b/src/Dock.Model.Mvvm/Core/DockableBase.cs @@ -18,6 +18,9 @@ public abstract class DockableBase : ObservableObject, IDockable private IDockable? _owner; private IDockable? _originalOwner; private IFactory? _factory; + private bool _isEmpty; + private bool _isCollapsable = true; + private double _proportion = double.NaN; private bool _canClose = true; private bool _canPin = true; private bool _canFloat = true; @@ -78,6 +81,30 @@ public IFactory? Factory set => SetProperty(ref _factory, value); } + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public bool IsEmpty + { + get => _isEmpty; + set => SetProperty(ref _isEmpty, value); + } + + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public bool IsCollapsable + { + get => _isCollapsable; + set => SetProperty(ref _isCollapsable, value); + } + + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public double Proportion + { + get => _proportion; + set => SetProperty(ref _proportion, value); + } + /// [DataMember(IsRequired = false, EmitDefaultValue = true)] public bool CanClose diff --git a/src/Dock.Model.ReactiveUI/Core/DockBase.cs b/src/Dock.Model.ReactiveUI/Core/DockBase.cs index 3be43ca0a..92be7c260 100644 --- a/src/Dock.Model.ReactiveUI/Core/DockBase.cs +++ b/src/Dock.Model.ReactiveUI/Core/DockBase.cs @@ -18,11 +18,8 @@ public abstract class DockBase : DockableBase, IDock private IDockable? _activeDockable; private IDockable? _defaultDockable; private IDockable? _focusedDockable; - private double _proportion = double.NaN; private DockMode _dock = DockMode.Center; - private bool _isCollapsable = true; private bool _isActive; - private bool _isEmpty; private int _openedDockablesCount; /// @@ -79,14 +76,6 @@ public IDockable? FocusedDockable } } - /// - [DataMember(IsRequired = false, EmitDefaultValue = true)] - public double Proportion - { - get => _proportion; - set => this.RaiseAndSetIfChanged(ref _proportion, value); - } - /// [DataMember(IsRequired = false, EmitDefaultValue = true)] public DockMode Dock @@ -103,14 +92,6 @@ public bool IsActive set => this.RaiseAndSetIfChanged(ref _isActive, value); } - /// - [DataMember(IsRequired = false, EmitDefaultValue = true)] - public bool IsEmpty - { - get => _isEmpty; - set => this.RaiseAndSetIfChanged(ref _isEmpty, value); - } - /// [DataMember(IsRequired = false, EmitDefaultValue = true)] public int OpenedDockablesCount @@ -119,14 +100,6 @@ public int OpenedDockablesCount set => this.RaiseAndSetIfChanged(ref _openedDockablesCount, value); } - /// - [DataMember(IsRequired = false, EmitDefaultValue = true)] - public bool IsCollapsable - { - get => _isCollapsable; - set => this.RaiseAndSetIfChanged(ref _isCollapsable, value); - } - /// [IgnoreDataMember] public bool CanGoBack => _navigateAdapter.CanGoBack; diff --git a/src/Dock.Model.ReactiveUI/Core/DockableBase.cs b/src/Dock.Model.ReactiveUI/Core/DockableBase.cs index 5116948ba..ec138b344 100644 --- a/src/Dock.Model.ReactiveUI/Core/DockableBase.cs +++ b/src/Dock.Model.ReactiveUI/Core/DockableBase.cs @@ -18,6 +18,9 @@ public abstract class DockableBase : ReactiveObject, IDockable private IDockable? _owner; private IDockable? _originalOwner; private IFactory? _factory; + private bool _isEmpty; + private bool _isCollapsable = true; + private double _proportion = double.NaN; private bool _canClose = true; private bool _canPin = true; private bool _canFloat = true; @@ -78,6 +81,30 @@ public IFactory? Factory set => this.RaiseAndSetIfChanged(ref _factory, value); } + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public bool IsEmpty + { + get => _isEmpty; + set => this.RaiseAndSetIfChanged(ref _isEmpty, value); + } + + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public bool IsCollapsable + { + get => _isCollapsable; + set => this.RaiseAndSetIfChanged(ref _isCollapsable, value); + } + + /// + [DataMember(IsRequired = false, EmitDefaultValue = true)] + public double Proportion + { + get => _proportion; + set => this.RaiseAndSetIfChanged(ref _proportion, value); + } + /// [DataMember(IsRequired = false, EmitDefaultValue = true)] public bool CanClose diff --git a/src/Dock.Model/Core/IDock.cs b/src/Dock.Model/Core/IDock.cs index 9901c7c07..e00f409b7 100644 --- a/src/Dock.Model/Core/IDock.cs +++ b/src/Dock.Model/Core/IDock.cs @@ -28,11 +28,6 @@ public interface IDock : IDockable /// IDockable? FocusedDockable { get; set; } - /// - /// Gets or sets splitter proportion. - /// - double Proportion { get; set; } - /// /// Gets or sets docking mode. /// @@ -43,16 +38,6 @@ public interface IDock : IDockable /// bool IsActive { get; set; } - /// - /// Gets if the dockable is empty. - /// - bool IsEmpty { get; set; } - - /// - /// Gets or sets if the Dock collapses when all its children are removed. - /// - bool IsCollapsable { get; set; } - /// /// Gets the number of currently opened and visible dockables /// diff --git a/src/Dock.Model/Core/IDockable.cs b/src/Dock.Model/Core/IDockable.cs index 410036e3c..f7b689c8d 100644 --- a/src/Dock.Model/Core/IDockable.cs +++ b/src/Dock.Model/Core/IDockable.cs @@ -38,6 +38,21 @@ public interface IDockable : IControlRecyclingIdProvider /// IFactory? Factory { get; set; } + /// + /// Gets if the dockable is empty. + /// + bool IsEmpty { get; set; } + + /// + /// Gets or sets if the dockable collapses when all its children are removed. + /// + bool IsCollapsable { get; set; } + + /// + /// Gets or sets splitter proportion. + /// + double Proportion { get; set; } + /// /// Gets or sets if the dockable can be closed. /// From 022e6b38a4ecd7a5c79e4cc19170b37a96f4e601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20S=CC=8Colte=CC=81s?= Date: Tue, 12 Nov 2024 15:19:05 +0100 Subject: [PATCH 2/6] Fix x:DataType for ProportionalDockControl --- .../Controls/ProportionalDockControl.axaml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Dock.Avalonia/Controls/ProportionalDockControl.axaml b/src/Dock.Avalonia/Controls/ProportionalDockControl.axaml index 32976b692..a814f9ba4 100644 --- a/src/Dock.Avalonia/Controls/ProportionalDockControl.axaml +++ b/src/Dock.Avalonia/Controls/ProportionalDockControl.axaml @@ -1,7 +1,8 @@ + xmlns:core="using:Dock.Model.Core" + xmlns:dmc="using:Dock.Model.Controls"> @@ -11,13 +12,16 @@ - +