public static bool DragDropSource(string name, ushort handleIdx, DragDropWindow window, DragDropTree tree, string payloadType, ImGuiDragDropFlags flags) { if (ImGui.BeginDragDropSource(flags)) { s_dragdropDataD[0] = (byte)window; s_dragdropDataD[1] = (byte)tree; Util.GetBytesGC0(handleIdx, ref s_tmpBytesForShort); Array.Copy(s_tmpBytesForShort, 0, s_dragdropDataD, 2, 2); IntPtr dataPtr; unsafe { fixed(byte *native = &s_dragdropDataD[0]) { dataPtr = (IntPtr)(native); } } ImGui.SetDragDropPayload(payloadType, dataPtr, s_dragdrop_size); ImGui.Text(name); ImGui.EndDragDropSource(); return(true); } return(false); }
public void DragDropWindowRemove() { if (DragDropWindow != null) { DragDropWindow.Close(); DragDropWindow = null; } }
public static bool DragDrop(string name, ushort handleIdx, DragDropWindow window, DragDropTree tree, string payloadType, ImGuiDragDropFlags flags, Action <DragDropWindow, DragDropTree, ushort, DragDropWindow, DragDropTree, ushort> action) { bool ret = DragDropTarget(handleIdx, window, tree, payloadType, flags, action); DragDropSource(name, handleIdx, window, tree, payloadType, flags); return(ret); }
private static void OnDragDropFromHierarchy(DragDropTree treeS, ushort handleIdxS, DragDropWindow windowT, DragDropTree treeT, ushort handleIdxT) { switch (windowT) { case DragDropWindow.Hierarchy: OnDragDropFromHierarchyToHierachy(treeS, handleIdxS, treeT, handleIdxT); break; default: Debug.LogError("未处理"); break; } }
public static void OnDragDropAction( DragDropWindow windowS, DragDropTree treeS, ushort handleIdxS, DragDropWindow windowT, DragDropTree treeT, ushort handleIdxT) { switch (windowS) { case DragDropWindow.Hierarchy: OnDragDropFromHierarchy(treeS, handleIdxS, windowT, treeT, handleIdxT); break; default: Debug.LogError("未处理"); break; } }
public static bool DragDropTarget(ushort handleIdx, DragDropWindow window, DragDropTree tree, string payloadType, ImGuiDragDropFlags flags, Action <DragDropWindow, DragDropTree, ushort, DragDropWindow, DragDropTree, ushort> action) { bool ret = false; if (ImGui.BeginDragDropTarget()) { var payload = ImGui.AcceptDragDropPayload(payloadType, flags); unsafe { if (payload.NativePtr != null) { IntPtr dataSource = payload.Data; System.Runtime.InteropServices.Marshal.Copy(dataSource, s_dragdropDataE, 0, s_dragdrop_size); DragDropWindow windowSource = (DragDropWindow)s_dragdropDataE[0]; DragDropTree treeSource = (DragDropTree)s_dragdropDataE[1]; ushort handleIdxSource = 0; unsafe { fixed(byte *pbyte = &s_dragdropDataE[2]) { handleIdxSource = *((ushort *)pbyte); } } if (action != null) { action(windowSource, treeSource, handleIdxSource, window, tree, handleIdx); } ret = true; } } ImGui.EndDragDropTarget(); } return(ret); }