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 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);
        }
        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);
        }
Exemple #4
0
        public static unsafe bool AcceptDragDropPayload(string type, out string payload, ImGuiDragDropFlags flags = ImGuiDragDropFlags.None)
        {
            ImGuiPayload *pload = AcceptDragDropPayload(type, flags);

            payload = (pload != null) ? Encoding.Default.GetString((byte *)pload->Data, pload->DataSize) : null;
            return(pload != null);
        }
Exemple #5
0
        public static unsafe bool AcceptDragDropPayload <T>(string type, out T payload, ImGuiDragDropFlags flags = ImGuiDragDropFlags.None)
            where T : unmanaged
        {
            ImGuiPayload *pload = AcceptDragDropPayload(type, flags);

            payload = (pload != null) ? Unsafe.Read <T>(pload->Data) : default;
            return(pload != null);
        }
 public abstract byte igBeginDragDropSource(ImGuiDragDropFlags flags);
 public abstract ImGuiPayload *igAcceptDragDropPayload(byte *type, ImGuiDragDropFlags flags);
 public static bool BeginDragDropSource(ImGuiDragDropFlags flags)
 {
     return(ImGui.BeginDragDropSource(flags));
 }