protected override bool OnDragDrop(Gdk.DragContext context, int x, int y, uint time) { ActionPaletteItem dropped = DND.Drop(context, null, time) as ActionPaletteItem; if (dropped == null) { return(false); } if (dropped.Node.Type != Gtk.UIManagerItemType.Menuitem && dropped.Node.Type != Gtk.UIManagerItemType.Menu && dropped.Node.Type != Gtk.UIManagerItemType.Toolitem && dropped.Node.Type != Gtk.UIManagerItemType.Separator) { return(false); } ActionTreeNode newNode = null; // Toolitems are copied, not moved using (wrapper.UndoManager.AtomicChange) { if (dropped.Node.ParentNode != null && dropped.Node.Type != Gtk.UIManagerItemType.Toolitem) { if (dropIndex < nodes.Count) { // Do nothing if trying to drop the node over the same node ActionTreeNode dropNode = nodes [dropIndex]; if (dropNode == dropped.Node) { return(false); } dropped.Node.ParentNode.Children.Remove(dropped.Node); // The drop position may have changed after removing the dropped node, // so get it again. dropIndex = nodes.IndexOf(dropNode); nodes.Insert(dropIndex, dropped.Node); } else { dropped.Node.ParentNode.Children.Remove(dropped.Node); nodes.Add(dropped.Node); dropIndex = nodes.Count - 1; } } else { newNode = new ActionTreeNode(Gtk.UIManagerItemType.Menuitem, null, dropped.Node.Action); nodes.Insert(dropIndex, newNode); } // Select the dropped node ActionMenuItem mi = (ActionMenuItem)menuItems [dropIndex]; mi.Select(); } return(base.OnDragDrop(context, x, y, time)); }
void Awake() { dragNDropUse = target as DragNDropUseInnerDrops; //dnd = new DND(); dnd = dragNDropUse.dragNDrop; }
public override void Wrap(object obj, bool initialized) { base.Wrap(obj, initialized); DND.DestSet(gtkfixed, true); gtkfixed.DragDrop += FixedDragDrop; gtkfixed.DragDataReceived += FixedDragDataReceived; }
void DragEnd(object obj, Gtk.DragEndArgs args) { Gtk.Invisible invis = obj as Gtk.Invisible; invis.DragEnd -= DragEnd; invis.Destroy(); if (DND.DragWidget != null) { ToolItemize(DND.Cancel(), dragIndex); } dragIndex = -1; }
void FixedDragDrop(object obj, Gtk.DragDropArgs args) { Gtk.Widget w = DND.Drop(args.Context, gtkfixed, args.Time); Widget ww = Widget.Lookup(w); if (ww != null) { gtkfixed.Put(w, args.X - DND.DragHotX, args.Y - DND.DragHotY); NotifyChildAdded(w); args.RetVal = true; ww.Select(); } }
public ActionItem(ActionTreeNode node, IMenuItemContainer parent, uint itemSpacing) { DND.SourceSet(this); this.parentMenu = parent; this.node = node; this.VisibleWindow = false; this.CanFocus = true; this.Events |= Gdk.EventMask.KeyPressMask; this.itemSpacing = itemSpacing; if (node.Action != null) { node.Action.ObjectChanged += OnActionChanged; } }
public virtual void ProcessDragBegin(Gdk.DragContext ctx, Gdk.EventMotion evt) { editOnRelease = false; ActionPaletteItem item = new ActionPaletteItem(node); if (ctx != null) { DND.Drag(parentMenu.Widget, ctx, item); } else { DND.Drag(parentMenu.Widget, evt, item); } }
public override void Wrap(object obj, bool initialized) { base.Wrap(obj, initialized); if (!initialized && AllowPlaceholders) { Placeholder ph = CreatePlaceholder(); box.PackStart(ph); NotifyChildAdded(ph); ph = CreatePlaceholder(); box.PackStart(ph); NotifyChildAdded(ph); box.Spacing = 6; } box.SizeAllocated += box_SizeAllocated; ContainerOrientation = obj is Gtk.HBox ? Gtk.Orientation.Horizontal : Gtk.Orientation.Vertical; DND.ClearFaults(this); }
internal ActionMenu(Widget wrapper, IMenuItemContainer parentMenu, ActionTreeNode node) { DND.DestSet(this, true); parentNode = node; this.parentMenu = parentMenu; this.wrapper = wrapper; this.nodes = node.Children; table = new Gtk.Table(0, 0, false); table.ColumnSpacing = 5; table.RowSpacing = 5; table.BorderWidth = 5; this.AppPaintable = true; Add(table); Fill(); parentNode.ChildNodeAdded += OnChildAdded; parentNode.ChildNodeRemoved += OnChildRemoved; }
protected override void DoSync() { DND.ClearFaults(this); Gtk.Orientation faultOrientation = Orientation == Gtk.Orientation.Horizontal ? Gtk.Orientation.Vertical : Gtk.Orientation.Horizontal; Gdk.Rectangle tbAlloc = toolbar.Allocation; Gtk.Widget[] children = toolbar.Children; if (children.Length == 0) { DND.AddFault(this, 0, faultOrientation, tbAlloc); return; } if (faultOrientation == Gtk.Orientation.Horizontal) { DND.AddHFault(this, 0, null, children[0]); DND.AddHFault(this, children.Length, children[children.Length - 1], null); } else { DND.AddVFault(this, 0, null, children[0]); DND.AddVFault(this, children.Length, children[children.Length - 1], null); } for (int i = 1; i < children.Length; i++) { if (faultOrientation == Gtk.Orientation.Horizontal) { DND.AddHFault(this, i, children[i - 1], children[i]); } else { DND.AddVFault(this, i, children[i - 1], children[i]); } } }
/* * FIXME: why was this needed? * protected override bool AllowPlaceholders { * get { * return InternalChildProperty != null; * } * } */ // DoSync() does two things: first, it makes sure that all of the // PackStart widgets have Position numbers less than all of the // PackEnd widgets. Second, it creates faults anywhere two widgets // could be split apart. The fault IDs correspond to the Position // a widget would have to be assigned to end up in that slot // (negated for PackEnd slots). // // Position/PackType: 0S 1S 2S 4E 3E // +----------------------+ // | AA BB CC DD EE | // +----------------------+ // Fault Id: 0 1 2 3 -5 -4 -3 protected override void DoSync() { if (!box.IsRealized) { return; } DND.ClearFaults(this); Gtk.Widget[] children = box.Children; if (children.Length == 0) { return; } Gtk.Widget[] sorted = new Gtk.Widget[children.Length]; int last_start = -1; bool hbox = ContainerOrientation == Gtk.Orientation.Horizontal; foreach (Gtk.Widget child in children) { Gtk.Box.BoxChild bc = box[child] as Gtk.Box.BoxChild; if (AutoSize[child]) { bool exp = hbox ? ChildHExpandable(child) : ChildVExpandable(child); if (bc.Expand != exp) { bc.Expand = exp; } if (bc.Fill != exp) { bc.Fill = exp; } } // Make sure all of the PackStart widgets are before // any PackEnd widgets in the list. if (bc.PackType == Gtk.PackType.Start) { if (bc.Position != ++last_start) { Array.Copy(sorted, last_start, sorted, last_start + 1, bc.Position - last_start); box.ReorderChild(child, last_start); } } if (!(child is Placeholder)) { sorted[bc.Position] = child; } } // The orientation of the faults is the opposite of the // orientation of the box Gtk.Orientation orientation = hbox ? Gtk.Orientation.Vertical : Gtk.Orientation.Horizontal; Gtk.SideType before = hbox ? Gtk.SideType.Left : Gtk.SideType.Top; Gtk.SideType after = hbox ? Gtk.SideType.Right : Gtk.SideType.Bottom; if (!Unselectable) { // If there are no PackStart widgets, we need a fault at the leading // edge. Otherwise if there's a widget at the leading edge, we need a // fault before it. if (last_start == -1) { DND.AddFault(this, 0, before, null); } else if (sorted[0] != null) { DND.AddFault(this, 0, before, sorted[0]); } // Add a fault between each pair of (non-placeholder) start widgets for (int i = 1; i <= last_start; i++) { if (sorted[i - 1] != null && sorted[i] != null) { DND.AddFault(this, i, orientation, sorted[i - 1], sorted[i]); } } // If there's a non-placeholder at the end of the PackStart // range, add a fault after it if (last_start > -1 && sorted[last_start] != null) { DND.AddFault(this, last_start + 1, after, sorted[last_start]); } // Now the PackEnd widgets if (last_start == sorted.Length - 1) { DND.AddFault(this, -(last_start + 1), after, null); } else if (sorted[last_start + 1] != null) { DND.AddFault(this, -(last_start + 1), after, sorted[last_start + 1]); } for (int i = last_start + 2; i < sorted.Length; i++) { if (sorted[i - 1] != null && sorted[i] != null) { DND.AddFault(this, -i, orientation, sorted[i - 1], sorted[i]); } } if (sorted.Length > last_start + 1 && sorted[sorted.Length - 1] != null) { DND.AddFault(this, -sorted.Length, before, sorted[sorted.Length - 1]); } } }
protected override bool OnDragDrop(Gdk.DragContext context, int x, int y, uint time) { ActionPaletteItem dropped = DND.Drop(context, null, time) as ActionPaletteItem; if (dropped == null) { return(false); } if (dropped.Node.Type != Gtk.UIManagerItemType.Menuitem && dropped.Node.Type != Gtk.UIManagerItemType.Menu && dropped.Node.Type != Gtk.UIManagerItemType.Toolitem && dropped.Node.Type != Gtk.UIManagerItemType.Separator) { return(false); } ActionTreeNode newNode = dropped.Node; if (dropped.Node.Type == Gtk.UIManagerItemType.Toolitem) { newNode = newNode.Clone(); newNode.Type = Gtk.UIManagerItemType.Menuitem; } Widget wrapper = Widget.Lookup(this); using (wrapper.UndoManager.AtomicChange) { if (dropIndex < actionTree.Children.Count) { // Do nothing if trying to drop the node over the same node ActionTreeNode dropNode = actionTree.Children [dropIndex]; if (dropNode == dropped.Node) { return(false); } if (newNode.ParentNode != null) { newNode.ParentNode.Children.Remove(newNode); } // The drop position may have changed after removing the dropped node, // so get it again. dropIndex = actionTree.Children.IndexOf(dropNode); actionTree.Children.Insert(dropIndex, newNode); } else { if (newNode.ParentNode != null) { newNode.ParentNode.Children.Remove(newNode); } actionTree.Children.Add(newNode); dropIndex = actionTree.Children.Count - 1; } // Select the dropped node ActionMenuItem mi = (ActionMenuItem)menuItems [dropIndex]; mi.Select(); } return(base.OnDragDrop(context, x, y, time)); }
public ActionMenuBar() { DND.DestSet(this, true); }
public ActionToolbar() { DND.DestSet(this, true); this.ShowArrow = false; }