1 module creator.widgets.dragdrop; 2 import creator.widgets; 3 import bindbc.imgui; 4 import inochi2d; 5 6 void incDragdropNodeList(Node node) { 7 enum ENTRY_SIZE = 48; 8 igPushID(node.uuid); 9 if (Part part = cast(Part)node) { 10 incTextureSlotUntitled("ICON", part.textures[0], ImVec2(ENTRY_SIZE-4, ENTRY_SIZE-4), 24, ImGuiWindowFlags.NoInputs); 11 } else { 12 incText(node.name); 13 } 14 igPopID(); 15 } 16 17 void incDragdropNodeList(Node[] nodes) { 18 enum ENTRY_SIZE = 48; 19 20 int i = 0; 21 int f = 0; 22 foreach(Node node; nodes) { 23 if (Part part = cast(Part)node) { 24 f++; 25 if (i++ != 0 && i%4 != 1) { 26 igSameLine(0, 4); 27 } 28 29 igPushID(part.uuid); 30 incTextureSlotUntitled("ICON", part.textures[0], ImVec2(ENTRY_SIZE-4, ENTRY_SIZE-4), 24, ImGuiWindowFlags.NoInputs); 31 igPopID(); 32 } 33 } 34 35 if (i < nodes.length) { 36 if (f > 0) igDummy(ImVec2(0, 4)); 37 38 foreach(Node node; nodes) { 39 if (Part part = cast(Part)node) continue; 40 incText(node.name); 41 } 42 } 43 } 44 45 /** 46 Begins fake drag/drop context 47 */ 48 void incBeginDragDropFake() { 49 auto storage = igGetStateStorage(); 50 auto ctx = igGetCurrentContext(); 51 ImGuiStorage_SetBool(storage, igGetID("DRAG_DROP_ACTIVE"), ctx.DragDropActive); 52 ImGuiStorage_SetInt(storage, igGetID("DRAG_DROP_FRAME_COUNT"), ctx.DragDropPayload.DataFrameCount); 53 ctx.DragDropActive = true; 54 ctx.DragDropPayload.DataFrameCount = ctx.FrameCount; 55 } 56 57 /** 58 Ends fake drag/drop context 59 */ 60 void incEndDragDropFake() { 61 auto storage = igGetStateStorage(); 62 auto ctx = igGetCurrentContext(); 63 bool active = ImGuiStorage_GetBool(storage, igGetID("DRAG_DROP_ACTIVE"), false); 64 int frameCount = ImGuiStorage_GetInt(storage, igGetID("DRAG_DROP_FRAME_COUNT"), -1); 65 ctx.DragDropActive = active; 66 ctx.DragDropPayload.DataFrameCount = frameCount; 67 }