sandnode_stack.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "imgui.h"
  2. #include "immapp/runner.h"
  3. #include "hello_imgui/hello_imgui.h"
  4. #include <string>
  5. #include <vector>
  6. struct ItemInfo
  7. {
  8. std::string Name;
  9. std::string Description;
  10. bool IsSelected = false;
  11. };
  12. std::vector<ItemInfo> AllInfo{
  13. {
  14. {"Italian Salad", "A delicious salad with tomatoes, mozzarella, basil, and olive oil."},
  15. {"Greek Salad", "A delicious salad with tomatoes, feta, olives, and olive oil."},
  16. {"Caesar Salad", "A delicious salad with lettuce, croutons, parmesan, and Caesar dressing."},
  17. {"Nicoise Salad", "A delicious salad with tuna, green beans, olives, and olive oil."},
  18. {"Waldorf Salad", "A delicious salad with apples, walnuts, celery, and mayonnaise."},
  19. }
  20. };
  21. void gui()
  22. {
  23. ImGui::BeginVertical("Infos");
  24. for(auto & info: AllInfo)
  25. {
  26. ImGui::PushID(&info);
  27. ImGui::BeginHorizontal("Info"); // All widgets layout horizontally here
  28. ImGui::Text("%s", info.Name.c_str()); // Display the name at the left
  29. ImGui::Spring(); // A flexible space that grows
  30. ImGui::Checkbox("", &info.IsSelected); // As a consequence, all checkbox are right-aligned
  31. ImGui::EndHorizontal();
  32. ImGui::PopID();
  33. }
  34. ImGui::EndVertical();
  35. }
  36. int main()
  37. {
  38. ImmApp::Run(gui, "Salads");
  39. return 0;
  40. }