MCPcopy Create free account
hub / github.com/Sven-vh/ImReflect / nested_reflection_test

Function nested_reflection_test

examples/include/imgui_app.cpp:471–534  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

469
470
471static void nested_reflection_test() {
472 ImGui::SeparatorText("Nested Struct / Class Reflection");
473 ImGui::PushID("nested reflection");
474 ImGui::Indent();
475
476 static Bar bar;
477
478 ImGui::Text("Nested Structs");
479 HelpMarker("You need to define the ``IMGUI_REFLECT`` macro for each struct, this determines what is reflected");
480 {
481 const std::string code = R"(struct Foo {
482 int a;
483 float b;
484 bool c;
485};
486IMGUI_REFLECT(Foo, a, b, c)
487
488struct Bar {
489 int x;
490 float y;
491 bool z;
492 Foo foo;
493};
494IMGUI_REFLECT(Bar, x, y, z, foo)";
495
496 IMGUI_SAMPLE_MULTI_CODE(code);
497
498 ImGui::Text("Output:");
499 ImReflect::Input("foo", bar);
500 }
501
502 ImGui::NewLine();
503
504 ImGui::Text("Nested Structs - pushing");
505 HelpMarker("Push setting inside another struct.");
506 {
507 auto config = ImSettings();
508 config.push<Foo>()
509 .push<int>()
510 .min(0)
511 .max(10)
512 .as_slider()
513 .pop()
514 .pop();
515
516 const std::string code = R"(auto config = ImSettings();
517config.push<Bar>()
518 .push<Foo>()
519 .push<int>()
520 .min(0)
521 .max(10)
522 .as_slider()
523 .pop() // int
524 .pop() // Foo
525 .pop(); // Bar)";
526 IMGUI_SAMPLE_MULTI_CODE(code);
527
528 ImGui::Text("Output:");

Callers 1

renderMethod · 0.85

Calls 2

HelpMarkerFunction · 0.85
InputFunction · 0.85

Tested by

no test coverage detected