MCPcopy Index your code
hub / github.com/SpaiR/imgui-java / show

Method show

example/src/main/java/ExampleImNodes.java:28–119  ·  view source on GitHub ↗
(final ImBoolean showImNodesWindow, final Graph graph)

Source from the content-addressed store, hash-verified

26 }
27
28 public static void show(final ImBoolean showImNodesWindow, final Graph graph) {
29 ImGui.setNextWindowSize(500, 400, ImGuiCond.Once);
30 ImGui.setNextWindowPos(ImGui.getMainViewport().getPosX() + 100, ImGui.getMainViewport().getPosY() + 100, ImGuiCond.Once);
31 if (ImGui.begin("ImNodes Demo", showImNodesWindow)) {
32 ImGui.text("This a demo graph editor for ImNodes");
33
34 ImGui.alignTextToFramePadding();
35 ImGui.text("Repo:");
36 ImGui.sameLine();
37 if (ImGui.button(URL)) {
38 try {
39 Desktop.getDesktop().browse(new URI(URL));
40 } catch (Exception e) {
41 e.printStackTrace();
42 }
43 }
44
45 ImNodes.editorContextSet(editorContext);
46 ImNodes.beginNodeEditor();
47
48 for (Graph.GraphNode node : graph.nodes.values()) {
49 ImNodes.beginNode(node.nodeId);
50
51 ImNodes.beginNodeTitleBar();
52 ImGui.text(node.getName());
53 ImNodes.endNodeTitleBar();
54
55 ImNodes.beginInputAttribute(node.getInputPinId(), ImNodesPinShape.CircleFilled);
56 ImGui.text("In");
57 ImNodes.endInputAttribute();
58
59 ImGui.sameLine();
60
61 ImNodes.beginOutputAttribute(node.getOutputPinId());
62 ImGui.text("Out");
63 ImNodes.endOutputAttribute();
64
65 ImNodes.endNode();
66 }
67
68 int uniqueLinkId = 1;
69 for (Graph.GraphNode node : graph.nodes.values()) {
70 if (graph.nodes.containsKey(node.outputNodeId)) {
71 ImNodes.link(uniqueLinkId++, node.getOutputPinId(), graph.nodes.get(node.outputNodeId).getInputPinId());
72 }
73 }
74
75 final boolean isEditorHovered = ImNodes.isEditorHovered();
76
77 ImNodes.miniMap(0.2f, ImNodesMiniMapLocation.BottomRight);
78 ImNodes.endNodeEditor();
79
80 if (ImNodes.isLinkCreated(LINK_A, LINK_B)) {
81 final Graph.GraphNode source = graph.findByOutput(LINK_A.get());
82 final Graph.GraphNode target = graph.findByInput(LINK_B.get());
83 if (source != null && target != null && source.outputNodeId != target.nodeId) {
84 source.outputNodeId = target.nodeId;
85 }

Callers 1

showMethod · 0.95

Calls 15

setNextWindowSizeMethod · 0.95
setNextWindowPosMethod · 0.95
getMainViewportMethod · 0.95
beginMethod · 0.95
textMethod · 0.95
sameLineMethod · 0.95
buttonMethod · 0.95
editorContextSetMethod · 0.95
beginNodeEditorMethod · 0.95
beginNodeMethod · 0.95
beginNodeTitleBarMethod · 0.95

Tested by

no test coverage detected