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

Allow dock items above dock item with "GroupOnlyById" to attach to the root #20

Open
izaksuilov opened this issue Feb 15, 2023 · 0 comments

Comments

@izaksuilov
Copy link

izaksuilov commented Feb 15, 2023

Now if you have dock with "GroupOnlyById", other docks that are above this one can't attach even to the root (top, right, bottom and left positions).

For example, "Floating Window - Hi" can attach to the bottom if it's above Dock Item "Hello" which doesn't have GroupOnlyById.

image

But if I want to attach this floating window to the bottom, the button disapears because the bottom Tabbed Group has GroupOnlyById.

image

I suggest to always allow to attach to the root like this

image

For that I suugest to replace existing code at NP.Avalonia.UniDock.DockManager:

private void OnPointerMoved(Point2D pointerScreenLocation)
{
if (_currentDockGroups == null)
{
return;
}
var pointerAboveGroups =
_currentDockGroups
.Where(gr => gr.Group.IsVisible && gr.Rect.ContainsPoint(pointerScreenLocation))
.Select(gr => gr.Group);
CurrentLeafObjToInsertWithRespectTo = pointerAboveGroups.FirstOrDefault();
var rootDockGroup = CurrentLeafObjToInsertWithRespectTo?.GetDockGroupRoot() as RootDockGroup;
if ((CurrentLeafObjToInsertWithRespectTo != null) &&
(CurrentLeafObjToInsertWithRespectTo is not RootDockGroup) &&
rootDockGroup?.GroupOnlyById == DraggedWindow?.GroupOnlyById)
{
CurrentRootDockGroup = rootDockGroup;
}
else
{
CurrentRootDockGroup = null;
}
}

With this code:

private void OnPointerMoved(Point2D pointerScreenLocation)
{
    if (_currentDockGroups == null)
    {
        CurrentLeafObjToInsertWithRespectTo = null;
    }
    else
    {
        var pointerAboveGroups =
            _currentDockGroups
                .Where(gr => gr.Group.IsVisible && gr.Rect.ContainsPoint(pointerScreenLocation))
                .OrderBy(gr => gr.Group.GetGroupWindow() != null)
                .Select(gr => gr.Group);

        CurrentLeafObjToInsertWithRespectTo = pointerAboveGroups.LastOrDefault();
    }

    RootDockGroup? rootDockGroup = null;

    if (CurrentLeafObjToInsertWithRespectTo != null && CurrentLeafObjToInsertWithRespectTo is not RootDockGroup)
    {
        rootDockGroup = CurrentLeafObjToInsertWithRespectTo?.GetDockGroupRoot() as RootDockGroup;
    }
    else if (CurrentLeafObjToInsertWithRespectTo == null && _rootGroups != null)
    {
        var pointerAboveRoots =
            _rootGroups
                .Where(gr => gr.Group.IsVisible && gr.Rect.ContainsPoint(pointerScreenLocation))
                .OrderBy(gr => gr.Group.GetGroupWindow() != null)
                .Select(gr => gr.Group);
        rootDockGroup = pointerAboveRoots.LastOrDefault();
    }

    CurrentRootDockGroup = rootDockGroup?.GroupOnlyById == DraggedWindow?.GroupOnlyById ? rootDockGroup : null;
}
@izaksuilov izaksuilov changed the title Allow dock items with "GroupOnlyById" to attach to root Allow dock items with "GroupOnlyById" to attach to the root Feb 15, 2023
@izaksuilov izaksuilov changed the title Allow dock items with "GroupOnlyById" to attach to the root Allow dock items above dock item with "GroupOnlyById" to attach to the root Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant