sandbox_stacklayout.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #if defined(IMGUI_BUNDLE_WITH_IMGUI_NODE_EDITOR)
  2. #include "imgui.h"
  3. #include "immapp/immapp.h"
  4. #include "imgui-node-editor/imgui_node_editor.h"
  5. namespace ed = ax::NodeEditor;
  6. void GuiNode()
  7. {
  8. // Basically a vertical layout with 2 inner horizontal layouts that contain text elements + a spring element
  9. ImGui::BeginVertical("V");
  10. {
  11. ImGui::BeginHorizontal("H");
  12. {
  13. ImGui::Text("Hello");
  14. ImGui::Spring();
  15. ImGui::Text("world"); // With the new version, this is clipped out!
  16. }
  17. ImGui::EndHorizontal();
  18. ImGui::BeginHorizontal("H2");
  19. {
  20. ImGui::Text("Hello");
  21. ImGui::Spring();
  22. ImGui::Text("world");
  23. ImGui::Text("And again");
  24. }
  25. ImGui::EndHorizontal();
  26. }
  27. ImGui::EndVertical();
  28. }
  29. void Gui()
  30. {
  31. // A simple node editor with a single node
  32. ed::Begin("Node editor");
  33. ed::BeginNode(ed::NodeId(1));
  34. {
  35. GuiNode();
  36. }
  37. ed::EndNode();
  38. ed::End();
  39. }
  40. int main(int, char**)
  41. {
  42. // Run the application using ImmApp (from ImGui Bundle)
  43. // This is simply a way to quickly setup an application with ImGui + Node Editor
  44. HelloImGui::RunnerParams runnerParams;
  45. runnerParams.callbacks.ShowGui = Gui;
  46. ImmApp::AddOnsParams addOnsParams;
  47. addOnsParams.withNodeEditor = true;
  48. ImmApp::Run(runnerParams, addOnsParams);
  49. return 0;
  50. }
  51. #else // #if defined(IMGUI_BUNDLE_WITH_IMGUI_NODE_EDITOR)
  52. int main() {}
  53. #endif