private void MoveChild(NodeViewChild child, int x, int y) { int xMax, yMax; Rectangle allocationView = Allocation; Rectangle allocationChild = child.Child.Allocation; x += child.Rectangle.X; y += child.Rectangle.Y; xMax = allocationView.Width - allocationChild.Width; yMax = allocationView.Height - allocationChild.Height; // Keep child within node view allocation if (x > 0 && x < xMax) { child.Rectangle.X = x; } else if (x < 0) { child.Rectangle.X = 0; } else if (x > xMax) { child.Rectangle.X = xMax; } if (y > 0 && y < yMax) { child.Rectangle.Y = y; } else if (y < 0) { child.Rectangle.Y = 0; } else if (y > yMax) { child.Rectangle.Y = yMax; } child.X = child.Rectangle.X; child.Y = child.Rectangle.Y; if (child.Child.Visible) { child.Child.QueueResize(); } // "raise" window, drawing occurs from start -> end of list _children.Remove(child); _children.Add(child); QueueDraw(); }
private void ChildButtonReleaseEvent(object sender, ButtonReleaseEventArgs args) { NodeViewChild child = GetChild((Widget)sender); Debug.Assert(child != null); if (args.Event.Button == 1) // GDK_BUTTON_PRIMARY { ((Node)child.Child).UnblockExpander(); } _action = NodeViewAction.None; args.RetVal = false; }
private void ChildButtonPressEventHandler(object sender, ButtonPressEventArgs args) { NodeViewChild child = GetChild((Widget)sender); Debug.Assert(child != null); if (args.Event.Button == 1) // GDK_BUTTON_PRIMARY { int x = (int)args.Event.X; int y = (int)args.Event.Y; bool inside = PointInRectangle(child.SouthEast, x, y); _action = inside ? NodeViewAction.Resize : NodeViewAction.DragChild; child.DragStart = new Point(x, y); Rectangle childAlloc = child.Child.Allocation; child.DragDelta = new Point(x - (childAlloc.X + childAlloc.Width), y - (childAlloc.Y + childAlloc.Height)); } args.RetVal = false; }
private void ChildMotionNotifyEventHandler(object sender, MotionNotifyEventArgs args) { NodeViewChild child = GetChild((Widget)sender); Debug.Assert(child != null); if (_action == NodeViewAction.None) { bool inside = PointInRectangle(child.SouthEast, (int)args.Event.X, (int)args.Event.Y); NodeCursorSet(inside ? NodeViewAction.Resize : NodeViewAction.None); } if ((args.Event.State & ModifierType.Button1Mask) != 0) { if (_action == NodeViewAction.DragChild) { ((Node)child.Child).BlockExpander(); MoveChild(child, (int)args.Event.X - child.DragStart.X, (int)args.Event.Y - child.DragStart.Y); } if (_action == NodeViewAction.Resize) { int w = (int)args.Event.X - child.Rectangle.X - child.DragDelta.X; int h = (int)args.Event.Y - child.Rectangle.Y - child.DragDelta.Y; child.Rectangle.Width = Math.Max(0, w); child.Rectangle.Height = Math.Max(0, h); child.Width = child.Rectangle.Width; child.Height = child.Rectangle.Height; child.Child.QueueResize(); QueueDraw(); } } args.RetVal = true; }