Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/Dock.Model/DockService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ private static void CopyDockGroup(IDockable source, IDockable target)
}
}

private static void CopyToolDockSettings(IToolDock source, IToolDock target)
{
target.IsExpanded = source.IsExpanded;
target.AutoHide = source.AutoHide;
target.GripMode = source.GripMode;
}

private static bool IsValidMove(IDockable sourceDockable, IDock sourceDockableOwner, IDock targetDock, IDockable targetDockable)
{
if (targetDockable is IDock)
Expand Down Expand Up @@ -158,6 +165,14 @@ private void SplitToolDockable(IDockable sourceDockable, IDock sourceDockableOwn
targetToolDock.Title = nameof(IToolDock);
targetToolDock.Alignment = operation.ToAlignment();
targetToolDock.VisibleDockables = factory.CreateList<IDockable>();
if (targetDock is IToolDock targetToolDockSource)
{
CopyToolDockSettings(targetToolDockSource, targetToolDock);
}
else if (sourceDockableOwner is IToolDock sourceToolDock)
{
CopyToolDockSettings(sourceToolDock, targetToolDock);
}
CopyDockGroup(sourceDockable, targetToolDock);

// Local split into a new (empty) dock: allow per Empty Dock Rule
Expand Down
44 changes: 44 additions & 0 deletions tests/Dock.Model.UnitTests/ToolDockGripModeInheritanceTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Dock.Model;
using Dock.Model.Avalonia;
using Dock.Model.Avalonia.Controls;
using Dock.Model.Controls;
using Dock.Model.Core;
using Xunit;

namespace Dock.Model.UnitTests;

public class ToolDockGripModeInheritanceTests
{
[Fact]
public void SplitToolDockable_Inherits_GripMode_From_TargetDock()
{
var factory = new Factory();
var root = factory.CreateRootDock();
root.VisibleDockables = factory.CreateList<IDockable>();

var toolDock = new ToolDock
{
GripMode = GripMode.AutoHide,
VisibleDockables = factory.CreateList<IDockable>()
};

var tool1 = new Tool { Id = "Tool1", Title = "Tool1" };
var tool2 = new Tool { Id = "Tool2", Title = "Tool2" };

toolDock.VisibleDockables.Add(tool1);
toolDock.VisibleDockables.Add(tool2);
toolDock.ActiveDockable = tool1;
root.VisibleDockables.Add(toolDock);

factory.InitLayout(root);

var manager = new DockManager(new DockService());
var executed = manager.ValidateTool(tool2, toolDock, DragAction.Move, DockOperation.Right, bExecute: true);

Assert.True(executed);
var newDock = tool2.Owner as IToolDock;
Assert.NotNull(newDock);
Assert.NotSame(toolDock, newDock);
Assert.Equal(GripMode.AutoHide, newDock!.GripMode);
}
}