Skip to content

Commit

Permalink
bugfixed: ImNodes example
Browse files Browse the repository at this point in the history
  • Loading branch information
dinau committed Dec 9, 2024
1 parent 1bfc321 commit 39b9d1c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
8 changes: 4 additions & 4 deletions examples/glfw_opengl3_imnodes/imgui.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ Size=400,400
Collapsed=0

[Window][Dear ImGui Demo]
Pos=647,14
Pos=659,12
Size=550,812
Collapsed=0

[Window][Nim: Dear ImGui test with Futhark]
Pos=39,392
Pos=14,400
Size=414,296
Collapsed=0

Expand Down Expand Up @@ -128,8 +128,8 @@ Size=403,232
Collapsed=0

[Window][Save & load example]
Pos=35,15
Size=578,370
Pos=16,10
Size=639,383
Collapsed=0

[Table][0xD0F0C6E3,2]
Expand Down
17 changes: 10 additions & 7 deletions examples/glfw_opengl3_imnodes/imnodeDemo.nim
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ proc save*(this: var SaveLoadEditor) =
imnodes_SaveCurrentEditorStateToIniFile("save_load.ini");
#// Dump our editor state as bytes into a file
var f = open("save_load.bytes", fmWrite)
defer: f.close
var fout = newFileStream(f)
defer: fout.close()
#// copy the node vector to file
Expand All @@ -138,27 +137,31 @@ proc load*(this: var SaveLoadEditor) =
except IOError:
#echo "save_load.bytes: not found !"
return
defer: f.close
var fin = newFileStream(f)
defer: fin.close()
#// copy nodes into memory
this.nodes.newSeq(fin.readInt32()) # this.nodes.resize(num_nodes)
if sizeof(int) == 4: # Select cpu 64bit or 32bit
this.nodes.newSeq(fin.readInt32()) # this.nodes.resize(num_nodes)
else:
this.nodes.newSeq(fin.readInt64()) # this.nodes.resize(num_nodes)
for nd in this.nodes.mitems:
fin.read(nd)
#// copy links into memory
this.links.newSeq(fin.readInt32()) #links_.resize(num_links)
if sizeof(int) == 4: # Select cpu 64bit or 32bit
this.links.newSeq(fin.readInt32()) # links_.resize(num_links)
else:
this.links.newSeq(fin.readInt64()) # links_.resize(num_links)
for nd in this.links.mitems:
fin.read(nd)
#// copy current_id into memory
this.current_id = fin.readInt32()
this.current_id = fin.readInt32() # current_id: cint is int32

#----------------------
# NodeEditorInitialize
#----------------------
var obj: SaveLoadEditor
proc NodeEditorInitialize*() =
# TODO ?
#imNodes_GetIO().LinkDetachWithModifierClick.Modifier[] = igGetIO().KeyCtrl
imNodes_GetIO().LinkDetachWithModifierClick.Modifier = getIOKeyCtrlPtr()
imNodes_PushAttributeFlag(ImNodesAttributeFlags_EnableLinkDetachWithDragClick.ImNodesAttributeFlags)
obj.load()

Expand Down
Binary file modified examples/glfw_opengl3_imnodes/save_load.bytes
Binary file not shown.
9 changes: 9 additions & 0 deletions examples/glfw_opengl3_imnodes/save_load.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
[editor]
panning=0,0

[node.1]
origin=18,7

[node.2]
origin=235,92

[node.4]
origin=429,180

0 comments on commit 39b9d1c

Please sign in to comment.