开发者

MonoDevelop.Components.Docking - Tabbed DockGroupType issue

Our application uses the MonoDevelop.Components.Docking framework in our Windows application. We last updated to the latest version in November 2010. I have come across some interesting behavior that occurs in the following situation:

  • Press the auto hide button of the first panel in a DockGroupType.Tabbed Parent开发者_如何学CGroup

  • Hold mouse over collapsed panel until it expands

  • Drag panel into center of the tabbed group (back to original spot) and drop

At this point the panel resizes to the size of the blue rectangle that showed where the panel would be dropped, and then undocks from the main window to float at that size. This only happens on the first item in a tabbed group. I found a commented out section of code in DockGroupItem.cs (line 112, GetDockTarget(..)) that seems as though it might deal with this. However, it references a DockPosition type that is not defined, CenterAfter. The method is below, with the commented out portion in bold:

public bool GetDockTarget (DockItem item, int px, int py, Gdk.Rectangle rect, out DockDelegate dockDelegate, out Gdk.Rectangle outrect)
{

 dockDelegate = null;                

 if (item != this.item && this.item.Visible && rect.Contains (px,py)) {

      int xdockMargin = (int) ((double)rect.Width * (1.0 - DockFrame.ItemDockCenterArea)) / 2;

      int ydockMargin = (int) ((double)rect.Height * (1.0 - DockFrame.ItemDockCenterArea)) / 2;

      DockPosition pos;                   

/*    if (ParentGroup.Type == DockGroupType.Tabbed) {

            rect = new Gdk.Rectangle (rect.X + xdockMargin, rect.Y + ydockMargin,rect.Width - xdockMargin*2, rect.Height - ydockMargin*2);

            pos = DockPosition.CenterAfter;

      }

*/    if (px <= rect.X + xdockMargin && ParentGroup.Type != DockGroupType.Horizontal) {

            outrect = new Gdk.Rectangle (rect.X, rect.Y, xdockMargin, rect.Height);

            pos = DockPosition.Left;

      }

      else if (px >= rect.Right - xdockMargin && ParentGroup.Type != DockGroupType.Horizontal) {

            outrect = new Gdk.Rectangle (rect.Right - xdockMargin, rect.Y, xdockMargin, rect.Height);

            pos = DockPosition.Right;

      }

      else if (py <= rect.Y + ydockMargin && ParentGroup.Type != DockGroupType.Vertical) {

            outrect = new Gdk.Rectangle (rect.X, rect.Y, rect.Width, ydockMargin);

            pos = DockPosition.Top;

      }

      else if (py >= rect.Bottom - ydockMargin && ParentGroup.Type != DockGroupType.Vertical) {

            outrect = new Gdk.Rectangle (rect.X, rect.Bottom - ydockMargin, rect.Width, ydockMargin);

            pos = DockPosition.Bottom;

      }

      else {

            outrect = new Gdk.Rectangle (rect.X + xdockMargin, rect.Y + ydockMargin, rect.Width - xdockMargin*2, rect.Height - ydockMargin*2);

            pos = DockPosition.Center;
      }          

      dockDelegate = delegate (DockItem dit) {

            DockGroupItem it = ParentGroup.AddObject (dit, pos, Id);

            it.SetVisible (true);

            ParentGroup.FocusItem (it);

      };

      return true;
 }

 outrect = Gdk.Rectangle.Zero;
 return false;
}

I have tried a few small things, but nothing as affected the behavior so far. Any ideas on what I could edit to get this working properly? Thanks!


To fix the problem above I added a check to see if the item being docked is the same as the first item in the tab group, if so, modifies the insertion index appropriately because trying to insert the item before itself in the group causes the float problem. Since its status was "AutoHide" it is still technically visible, so was kept in the tab group's list of visible objects. Changes are below.

DockGroup.cs (line 122) - commented out the index increase:

public DockGroupItem AddObject (DockItem obj, DockPosition pos, string relItemId)
{
...
else if (pos == DockPosition.CenterBefore || pos == DockPosition.Center) {
                if (type != DockGroupType.Tabbed)
                    gitem = Split (DockGroupType.Tabbed, pos == DockPosition.CenterBefore, obj, npos);
                else {
                    //if (pos == DockPosition.Center) // removed to fix issue with drag/docking the 1st tab item after autohiding 
                        //npos++;
                    gitem = new DockGroupItem (Frame, obj);
                    dockObjects.Insert (npos, gitem);
                    gitem.ParentGroup = this;
                }
            }
            ResetVisibleGroups ();
            return gitem;
}

DockGroup.cs (line 912) - added check for same item

internal override bool GetDockTarget (DockItem item, int px, int py, out DockDelegate dockDelegate, out Gdk.Rectangle rect)
        {
            if (!Allocation.Contains (px, py) || VisibleObjects.Count == 0) {
                dockDelegate = null;
                rect = Gdk.Rectangle.Zero;
                return false;
            }

            if (type == DockGroupType.Tabbed) {
                // this is a fix for issue with drag/docking the 1st tab item after autohiding it
                int pos = 0;
                if (item.Id == ((DockGroupItem)VisibleObjects[0]).Id)
                {
                    pos++;
                }

                // Tabs can only contain DockGroupItems
                return ((DockGroupItem)VisibleObjects[pos]).GetDockTarget (item, px, py, Allocation, out dockDelegate, out rect);
            }
...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜