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

fix: prevent closing dockables which should not be closable #316

Merged
merged 3 commits into from
Mar 11, 2024
Merged
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
14 changes: 7 additions & 7 deletions src/Dock.Model/FactoryBase.Dockable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public virtual void SwapDockable(IDock sourceDock, IDock targetDock, IDockable s
var originalTargetDockable = targetDock.VisibleDockables[targetIndex];
sourceDock.VisibleDockables[sourceIndex] = originalTargetDockable;
targetDock.VisibleDockables[targetIndex] = originalSourceDockable;

InitDockable(originalSourceDockable, targetDock);
InitDockable(originalTargetDockable, sourceDock);

Expand Down Expand Up @@ -309,7 +309,7 @@ public virtual void PinDockable(IDockable dockable)
{
return;
}

var isVisible = false;

if (toolDock.VisibleDockables is not null)
Expand Down Expand Up @@ -349,7 +349,7 @@ public virtual void PinDockable(IDockable dockable)
break;
}
}

if (toolDock.VisibleDockables is not null)
{
RemoveVisibleDockable(toolDock, dockable);
Expand Down Expand Up @@ -458,7 +458,7 @@ public virtual void PinDockable(IDockable dockable)

AddVisibleDockable(toolDock, dockable);
OnDockableAdded(dockable);

// TODO: Handle ActiveDockable state.
// TODO: Handle IsExpanded property of IToolDock.
// TODO: Handle AutoHide property of IToolDock.
Expand Down Expand Up @@ -519,7 +519,7 @@ public virtual void FloatDockable(IDockable dockable)
/// <inheritdoc/>
public virtual void CloseDockable(IDockable dockable)
{
if (dockable.OnClose())
if (dockable.CanClose && dockable.OnClose())
{
RemoveDockable(dockable, true);
OnDockableClosed(dockable);
Expand Down Expand Up @@ -577,7 +577,7 @@ public virtual void CloseLeftDockables(IDockable dockable)
{
return;
}

CloseDockablesRange(dock, 0, indexOf - 1);
}

Expand All @@ -594,7 +594,7 @@ public virtual void CloseRightDockables(IDockable dockable)
{
return;
}

CloseDockablesRange(dock, indexOf + 1, dock.VisibleDockables.Count - 1);
}

Expand Down
Loading