public override bool DragAndDrop_CanAcceptPackage(Package p) { if (!m_AllowReorder) return false; if (p.Name == "TabButtonMove") return true; return false; }
public static void ControlDeleted(Controls.Control control) { if (SourceControl == control) { SourceControl = null; CurrentPackage = null; HoveredControl = null; m_LastPressedControl = null; } if (m_LastPressedControl == control) m_LastPressedControl = null; if (HoveredControl == control) HoveredControl = null; if (m_NewHoveredControl == control) m_NewHoveredControl = null; }
public override void DragAndDrop_StartDragging(Package package, int x, int y) { DragAndDrop.SourceControl = Parent; DragAndDrop.SourceControl.DragAndDrop_StartDragging(package, x, y); }
private static bool ShouldStartDraggingControl( int x, int y ) { // We're not holding a control down.. if (m_LastPressedControl == null) return false; // Not been dragged far enough int length = Math.Abs(x - m_LastPressedPos.X) + Math.Abs(y - m_LastPressedPos.Y); if (length < 5) return false; // Create the dragging package CurrentPackage = m_LastPressedControl.DragAndDrop_GetPackage(m_LastPressedPos.X, m_LastPressedPos.Y); // We didn't create a package! if (CurrentPackage == null) { m_LastPressedControl = null; SourceControl = null; return false; } // Now we're dragging something! SourceControl = m_LastPressedControl; InputHandler.MouseFocus = null; m_LastPressedControl = null; CurrentPackage.DrawControl = null; // Some controls will want to decide whether they should be dragged at that moment. // This function is for them (it defaults to true) if (!SourceControl.DragAndDrop_ShouldStartDrag()) { SourceControl = null; CurrentPackage = null; return false; } SourceControl.DragAndDrop_StartDragging(CurrentPackage, m_LastPressedPos.X, m_LastPressedPos.Y); return true; }
public static bool Start(Controls.Control control, Package package) { if (CurrentPackage != null) { return false; } CurrentPackage = package; SourceControl = control; return true; }
// giver public virtual void DragAndDrop_StartDragging(Package package, int x, int y) { package.HoldOffset = CanvasPosToLocal(new Point(x, y)); package.DrawControl = this; }
// receiver public virtual void DragAndDrop_HoverLeave(Package p) { }
// receiver public virtual bool DragAndDrop_HandleDrop(Package p, int x, int y) { DragAndDrop.SourceControl.Parent = this; return true; }
private bool AddDown(Package p) { Parent.MovePaneVertically(DraggedPane, 0, false); return false; }
public override bool DragAndDrop_HandleDrop(Package p, int x, int y) { Vector2i pos = CanvasPosToLocal(new Vector2i(x, y)); Pos dir = GetDroppedTabDirection(pos.X, pos.Y); DockedTabControl addTo = m_DockedTabControl; if (dir == Pos.Fill && addTo == null) return false; if (dir != Pos.Fill) { DockBase dock = GetChildDock(dir); addTo = dock.m_DockedTabControl; if (!m_DropFar) dock.BringToFront(); else dock.SendToBack(); } if (p.Name == "TabButtonMove") { TabButton tabButton = DragAndDrop.SourceControl as TabButton; if (null == tabButton) return false; addTo.AddPage(tabButton); } if (p.Name == "TabWindowMove") { DockedTabControl tabControl = DragAndDrop.SourceControl as DockedTabControl; if (null == tabControl) return false; if (tabControl == addTo) return false; tabControl.MoveTabsTo(addTo); } Invalidate(); return true; }
public override bool DragAndDrop_CanAcceptPackage(Package p) { // A TAB button dropped if (p.Name == "TabButtonMove") return true; // a TAB window dropped if (p.Name == "TabWindowMove") return true; return false; }
public override bool DragAndDrop_HandleDrop(Package p, int x, int y) { Point LocalPos = CanvasPosToLocal(new Point(x, y)); TabButton button = DragAndDrop.SourceControl as TabButton; TabControl tabControl = Parent as TabControl; if (tabControl != null && button != null) { if (button.TabControl != tabControl) { // We've moved tab controls! tabControl.AddPage(button); } } Control droppedOn = GetControlAt(LocalPos.X, LocalPos.Y); if (droppedOn != null && droppedOn != this) { Point dropPos = droppedOn.CanvasPosToLocal(new Point(x, y)); DragAndDrop.SourceControl.BringNextToControl(droppedOn, dropPos.X > droppedOn.Width/2); } else { DragAndDrop.SourceControl.BringToFront(); } return true; }
public override void DragAndDrop_HoverLeave(Package p) { if (m_TabDragControl != null) { RemoveChild(m_TabDragControl, false); // [omeg] need to do that explicitely m_TabDragControl.Dispose(); } m_TabDragControl = null; }
public override void DragAndDrop_HoverEnter(Package p, int x, int y) { if (m_TabDragControl != null) { throw new InvalidOperationException("ERROR! TabStrip::DragAndDrop_HoverEnter"); } m_TabDragControl = new Highlight(this); m_TabDragControl.MouseInputEnabled = false; m_TabDragControl.SetSize(3, Height); }
public override void DragAndDrop_Hover(Package p, int x, int y) { Point localPos = CanvasPosToLocal(new Point(x, y)); Control droppedOn = GetControlAt(localPos.X, localPos.Y); if (droppedOn != null && droppedOn != this) { Point dropPos = droppedOn.CanvasPosToLocal(new Point(x, y)); m_TabDragControl.SetBounds(new Rectangle(0, 0, 3, Height)); m_TabDragControl.BringToFront(); m_TabDragControl.SetPosition(droppedOn.X - 1, 0); if (dropPos.X > droppedOn.Width/2) { m_TabDragControl.MoveBy(droppedOn.Width - 1, 0); } m_TabDragControl.Dock = Pos.None; } else { m_TabDragControl.Dock = Pos.Left; m_TabDragControl.BringToFront(); } }
public override bool DragAndDrop_HandleDrop(Package p, int x, int y) { return dropAction.Invoke(p); }
private bool AddCenter(Package p) { Parent.MovePane(DraggedPane, PaneGroup); return false; }
public override void DragAndDrop_Hover(Package p, int x, int y) { Vector2i pos = CanvasPosToLocal(new Vector2i(x, y)); Pos dir = GetDroppedTabDirection(pos.X, pos.Y); if (dir == Pos.Fill) { if (null == m_DockedTabControl) { m_HoverRect = new Rectangle(0,0,0,0); return; } m_HoverRect = InnerBounds; return; } m_HoverRect = RenderBounds; int HelpBarWidth = 0; if (dir == Pos.Left) { HelpBarWidth = (int)(m_HoverRect.Width * 0.25f); m_HoverRect.Width = HelpBarWidth; } if (dir == Pos.Right) { HelpBarWidth = (int)(m_HoverRect.Width * 0.25f); m_HoverRect.X = m_HoverRect.Width - HelpBarWidth; m_HoverRect.Width = HelpBarWidth; } if (dir == Pos.Top) { HelpBarWidth = (int)(m_HoverRect.Height * 0.25f); m_HoverRect.Height = HelpBarWidth; } if (dir == Pos.Bottom) { HelpBarWidth = (int)(m_HoverRect.Height * 0.25f); m_HoverRect.Y = m_HoverRect.Height - HelpBarWidth; m_HoverRect.Height = HelpBarWidth; } if ((dir == Pos.Top || dir == Pos.Bottom) && !m_DropFar) { if (m_Left != null && m_Left.IsVisible) { m_HoverRect.X += m_Left.Width; m_HoverRect.Width -= m_Left.Width; } if (m_Right != null && m_Right.IsVisible) { m_HoverRect.Width -= m_Right.Width; } } if ((dir == Pos.Left || dir == Pos.Right) && !m_DropFar) { if (m_Top != null && m_Top.IsVisible) { m_HoverRect.Y += m_Top.Height; m_HoverRect.Height -= m_Top.Height; } if (m_Bottom != null && m_Bottom.IsVisible) { m_HoverRect.Height -= m_Bottom.Height; } } }
// receiver public virtual bool DragAndDrop_CanAcceptPackage(Package p) { return false; }
public override void DragAndDrop_HoverEnter(Package p, int x, int y) { m_DrawHover = true; }
// receiver public virtual void DragAndDrop_HoverEnter(Package p, int x, int y) { }
public override void DragAndDrop_HoverLeave(Package p) { m_DrawHover = false; }
// giver public virtual void DragAndDrop_SetPackage(bool draggable, String name = "", object userData = null) { if (m_DragAndDrop_Package == null) { m_DragAndDrop_Package = new Package(); m_DragAndDrop_Package.IsDraggable = draggable; m_DragAndDrop_Package.Name = name; m_DragAndDrop_Package.UserData = userData; } }
private bool AddLeft(Package p) { Parent.MovePaneHorizontally(DraggedPane, 0, false); return false; }
public override bool DragAndDrop_CanAcceptPackage(Package p) { if (p.Name == "TabButtonMove") PaneManager.ShowDockHelper(this); return base.DragAndDrop_CanAcceptPackage(p); }
private bool AddRigth(Package p) { Parent.MovePaneHorizontally(DraggedPane, 0, true); return false; }
private static bool onDrop(int x, int y) { bool success = false; if (HoveredControl != null) { HoveredControl.DragAndDrop_HoverLeave(CurrentPackage); success = HoveredControl.DragAndDrop_HandleDrop(CurrentPackage, x, y); } // Report back to the source control, to tell it if we've been successful. SourceControl.DragAndDrop_EndDragging(success, x, y); CurrentPackage = null; SourceControl = null; return true; }
private bool AddUp(Package p) { Console.WriteLine("AddUp"); Parent.MovePaneVertically(DraggedPane, 0, true); return false; }
public override bool DragAndDrop_CanAcceptPackage(Package p) { return true; }
private bool AddLeft(Package p) { PaneManager.MovePaneHorizontally(DraggedPane,PaneGroup,0,false); return false; }