Skip to content

Commit

Permalink
Move properties to IDockable
Browse files Browse the repository at this point in the history
  • Loading branch information
wieslawsoltes committed Nov 12, 2024
1 parent ec36430 commit 2682e08
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 118 deletions.
50 changes: 1 addition & 49 deletions src/Dock.Model.Avalonia/Core/DockBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,7 @@ public abstract class DockBase : DockableBase, IDock
AvaloniaProperty.RegisterDirect<DockBase, IDockable?>(nameof(FocusedDockable), o => o.FocusedDockable, (o, v) => o.FocusedDockable = v);

/// <summary>
/// Defines the <see cref="Proportion"/> property.
/// </summary>
public static readonly DirectProperty<DockBase, double> ProportionProperty =
AvaloniaProperty.RegisterDirect<DockBase, double>(nameof(Proportion), o => o.Proportion, (o, v) => o.Proportion = v, double.NaN);

/// <summary>
/// Defines the <see cref="Proportion"/> property.
/// Defines the <see cref="Dock"/> property.
/// </summary>
public static readonly DirectProperty<DockBase, DockMode> DockProperty =
AvaloniaProperty.RegisterDirect<DockBase, DockMode>(nameof(Dock), o => o.Dock, (o, v) => o.Dock = v);
Expand All @@ -68,24 +62,12 @@ public abstract class DockBase : DockableBase, IDock
public static readonly DirectProperty<DockBase, bool> IsActiveProperty =
AvaloniaProperty.RegisterDirect<DockBase, bool>(nameof(IsActive), o => o.IsActive, (o, v) => o.IsActive = v);

/// <summary>
/// Defines the <see cref="IsEmpty"/> property.
/// </summary>
public static readonly DirectProperty<DockBase, bool> IsEmptyProperty =
AvaloniaProperty.RegisterDirect<DockBase, bool>(nameof(IsEmpty), o => o.IsEmpty, (o, v) => o.IsEmpty = v);

/// <summary>
/// Defines the <see cref="OpenedDockablesCount"/> property.
/// </summary>
public static readonly DirectProperty<DockBase, int> OpenedDockablesCountProperty =
AvaloniaProperty.RegisterDirect<DockBase, int>(nameof(OpenedDockablesCount), o => o.OpenedDockablesCount, (o, v) => o.OpenedDockablesCount = v);

/// <summary>
/// Defines the <see cref="IsCollapsable"/> property.
/// </summary>
public static readonly DirectProperty<DockBase, bool> IsCollapsableProperty =
AvaloniaProperty.RegisterDirect<DockBase, bool>(nameof(IsCollapsable), o => o.IsCollapsable, (o, v) => o.IsCollapsable = v, true);

/// <summary>
/// Defines the <see cref="CanGoBack"/> property.
/// </summary>
Expand All @@ -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;
Expand Down Expand Up @@ -175,15 +154,6 @@ public IDockable? FocusedDockable
}
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
[JsonPropertyName("Proportion")]
public double Proportion
{
get => _proportion;
set => SetAndRaise(ProportionProperty, ref _proportion, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
[JsonPropertyName("Dock")]
Expand All @@ -202,15 +172,6 @@ public bool IsActive
set => SetAndRaise(IsActiveProperty, ref _isActive, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
[JsonPropertyName("IsEmpty")]
public bool IsEmpty
{
get => _isEmpty;
set => SetAndRaise(IsEmptyProperty, ref _isEmpty, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
[JsonIgnore]
Expand All @@ -220,15 +181,6 @@ public int OpenedDockablesCount
set => SetAndRaise(OpenedDockablesCountProperty, ref _openedDockablesCount, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
[JsonPropertyName("IsCollapsable")]
public bool IsCollapsable
{
get => _isCollapsable;
set => SetAndRaise(IsCollapsableProperty, ref _isCollapsable, value);
}

/// <inheritdoc/>
[IgnoreDataMember]
[JsonIgnore]
Expand Down
48 changes: 48 additions & 0 deletions src/Dock.Model.Avalonia/Core/DockableBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@ public abstract class DockableBase : StyledElement, IDockable
public static readonly DirectProperty<DockableBase, IFactory?> FactoryProperty =
AvaloniaProperty.RegisterDirect<DockableBase, IFactory?>(nameof(Factory), o => o.Factory, (o, v) => o.Factory = v);

/// <summary>
/// Defines the <see cref="IsEmpty"/> property.
/// </summary>
public static readonly DirectProperty<DockableBase, bool> IsEmptyProperty =
AvaloniaProperty.RegisterDirect<DockableBase, bool>(nameof(IsEmpty), o => o.IsEmpty, (o, v) => o.IsEmpty = v);

/// <summary>
/// Defines the <see cref="IsCollapsable"/> property.
/// </summary>
public static readonly DirectProperty<DockableBase, bool> IsCollapsableProperty =
AvaloniaProperty.RegisterDirect<DockableBase, bool>(nameof(IsCollapsable), o => o.IsCollapsable, (o, v) => o.IsCollapsable = v, true);

/// <summary>
/// Defines the <see cref="Proportion"/> property.
/// </summary>
public static readonly DirectProperty<DockBase, double> ProportionProperty =
AvaloniaProperty.RegisterDirect<DockBase, double>(nameof(Proportion), o => o.Proportion, (o, v) => o.Proportion = v, double.NaN);

/// <summary>
/// Defines the <see cref="CanClose"/> property.
/// </summary>
Expand All @@ -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;
Expand Down Expand Up @@ -153,6 +174,33 @@ public IFactory? Factory
set => SetAndRaise(FactoryProperty, ref _factory, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
[JsonPropertyName("IsEmpty")]
public bool IsEmpty
{
get => _isEmpty;
set => SetAndRaise(IsEmptyProperty, ref _isEmpty, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
[JsonPropertyName("IsCollapsable")]
public bool IsCollapsable
{
get => _isCollapsable;
set => SetAndRaise(IsCollapsableProperty, ref _isCollapsable, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
[JsonPropertyName("Proportion")]
public double Proportion
{
get => _proportion;
set => SetAndRaise(ProportionProperty, ref _proportion, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
[JsonPropertyName("CanClose")]
Expand Down
27 changes: 0 additions & 27 deletions src/Dock.Model.Mvvm/Core/DockBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>
/// Initializes new instance of the <see cref="DockBase"/> class.
Expand Down Expand Up @@ -79,14 +76,6 @@ public IDockable? FocusedDockable
}
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public double Proportion
{
get => _proportion;
set => SetProperty(ref _proportion, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public DockMode Dock
Expand All @@ -103,22 +92,6 @@ public bool IsActive
set => SetProperty(ref _isActive, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public bool IsEmpty
{
get => _isEmpty;
set => SetProperty(ref _isEmpty, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public bool IsCollapsable
{
get => _isCollapsable;
set => SetProperty(ref _isCollapsable, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public int OpenedDockablesCount
Expand Down
27 changes: 27 additions & 0 deletions src/Dock.Model.Mvvm/Core/DockableBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -78,6 +81,30 @@ public IFactory? Factory
set => SetProperty(ref _factory, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public bool IsEmpty
{
get => _isEmpty;
set => SetProperty(ref _isEmpty, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public bool IsCollapsable
{
get => _isCollapsable;
set => SetProperty(ref _isCollapsable, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public double Proportion
{
get => _proportion;
set => SetProperty(ref _proportion, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public bool CanClose
Expand Down
27 changes: 0 additions & 27 deletions src/Dock.Model.ReactiveUI/Core/DockBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>
Expand Down Expand Up @@ -79,14 +76,6 @@ public IDockable? FocusedDockable
}
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public double Proportion
{
get => _proportion;
set => this.RaiseAndSetIfChanged(ref _proportion, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public DockMode Dock
Expand All @@ -103,14 +92,6 @@ public bool IsActive
set => this.RaiseAndSetIfChanged(ref _isActive, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public bool IsEmpty
{
get => _isEmpty;
set => this.RaiseAndSetIfChanged(ref _isEmpty, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public int OpenedDockablesCount
Expand All @@ -119,14 +100,6 @@ public int OpenedDockablesCount
set => this.RaiseAndSetIfChanged(ref _openedDockablesCount, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public bool IsCollapsable
{
get => _isCollapsable;
set => this.RaiseAndSetIfChanged(ref _isCollapsable, value);
}

/// <inheritdoc/>
[IgnoreDataMember]
public bool CanGoBack => _navigateAdapter.CanGoBack;
Expand Down
27 changes: 27 additions & 0 deletions src/Dock.Model.ReactiveUI/Core/DockableBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -78,6 +81,30 @@ public IFactory? Factory
set => this.RaiseAndSetIfChanged(ref _factory, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public bool IsEmpty
{
get => _isEmpty;
set => this.RaiseAndSetIfChanged(ref _isEmpty, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public bool IsCollapsable
{
get => _isCollapsable;
set => this.RaiseAndSetIfChanged(ref _isCollapsable, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public double Proportion
{
get => _proportion;
set => this.RaiseAndSetIfChanged(ref _proportion, value);
}

/// <inheritdoc/>
[DataMember(IsRequired = false, EmitDefaultValue = true)]
public bool CanClose
Expand Down
15 changes: 0 additions & 15 deletions src/Dock.Model/Core/IDock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ public interface IDock : IDockable
/// </summary>
IDockable? FocusedDockable { get; set; }

/// <summary>
/// Gets or sets splitter proportion.
/// </summary>
double Proportion { get; set; }

/// <summary>
/// Gets or sets docking mode.
/// </summary>
Expand All @@ -43,16 +38,6 @@ public interface IDock : IDockable
/// </summary>
bool IsActive { get; set; }

/// <summary>
/// Gets if the dockable is empty.
/// </summary>
bool IsEmpty { get; set; }

/// <summary>
/// Gets or sets if the Dock collapses when all its children are removed.
/// </summary>
bool IsCollapsable { get; set; }

/// <summary>
/// Gets the number of currently opened and visible dockables
/// </summary>
Expand Down
Loading

0 comments on commit 2682e08

Please sign in to comment.