@@ -6621,6 +6621,79 @@ void RegisterTests_Capture(ImGuiTestEngine* e)
6621
6621
ctx->PopupCloseAll ();
6622
6622
};
6623
6623
6624
+ // ## For FAQ entry
6625
+ t = IM_REGISTER_TEST (e, " capture" , " capture_faq_idstack_gif" );
6626
+ t->GuiFunc = [](ImGuiTestContext* ctx)
6627
+ {
6628
+ auto & vars = ctx->GenericVars ;
6629
+ struct Object { ImVec2 pos; };
6630
+ static Object* objects[3 ] = { (Object*)&vars.FloatArray [0 ], (Object*)&vars.FloatArray [2 ], (Object*)&vars.FloatArray [4 ] };
6631
+
6632
+ ImGui::Begin (" Incorrect!" );
6633
+ ImGui::DragFloat2 (" My value" , &objects[0 ]->pos .x );
6634
+ ImGui::DragFloat2 (" My value" , &objects[1 ]->pos .x );
6635
+ ImGui::DragFloat2 (" My value" , &objects[2 ]->pos .x );
6636
+ ImGui::End ();
6637
+
6638
+ ImGui::Begin (" Correct!" );
6639
+ ImGui::DragFloat2 (" My value" , &objects[0 ]->pos .x );
6640
+ ImGui::DragFloat2 (" My value##2" , &objects[1 ]->pos .x );
6641
+ ImGui::DragFloat2 (" My value##3" , &objects[2 ]->pos .x );
6642
+ ImGui::End ();
6643
+
6644
+ ImGui::Begin (" Also Correct!" );
6645
+ for (int row = 0 ; row < 3 ; row++)
6646
+ {
6647
+ ImGui::PushID (row);
6648
+ ImGui::DragFloat2 (" My value" , &objects[row]->pos .x );
6649
+ ImGui::PopID ();
6650
+ }
6651
+ ImGui::End ();
6652
+ };
6653
+ t->TestFunc = [](ImGuiTestContext* ctx)
6654
+ {
6655
+ const char * windows[3 ] = { " Incorrect!" , " Correct!" , " Also Correct!" };
6656
+ auto & vars = ctx->GenericVars ;
6657
+
6658
+ // Hidden setup
6659
+ ImVec2 window_size = ImVec2 (280 , ImGui::GetFrameHeightWithSpacing () * 5 );
6660
+ ImVec2 window_offset = ImVec2 (0 , window_size.y + ImGui::GetStyle ().ItemSpacing .y * 2 );
6661
+ for (int step = 0 ; step < 3 ; step++)
6662
+ ctx->WindowResize (windows[step], window_size);
6663
+ for (int step = 1 ; step < 3 ; step++)
6664
+ ctx->WindowMove (windows[step], ctx->WindowInfo (windows[step - 1 ]).Window ->Pos + window_offset);
6665
+
6666
+ // Capture
6667
+ ctx->CaptureSetExtension (" .gif" );
6668
+ for (int step = 0 ; step < 3 ; step++)
6669
+ ctx->CaptureAddWindow (windows[step]);
6670
+ ctx->CaptureBeginVideo ();
6671
+
6672
+ ImVec2 field_offset (0 , ImGui::GetFrameHeightWithSpacing ());
6673
+ for (int step = 0 ; step < 3 ; step++)
6674
+ {
6675
+ ctx->SetRef (windows[step]);
6676
+ vars.Clear (); // Reset all to 0
6677
+ ctx->WindowFocus (" " ); // Make more visible
6678
+
6679
+ // This is tricky: because the test engine relies on ID we can't naturally aim at fields easily.
6680
+ // So we query position and use position as a base to derive others.
6681
+ ImGuiTestItemInfo info = ctx->ItemInfo (step == 2 ? " $$0/My value/$$0" : " My value/$$0" );
6682
+ ImVec2 p = info.RectFull .GetCenter ();
6683
+ if (step == 0 )
6684
+ p -= field_offset * 2 ; // IN THE CASE OF DUPLICATE ID, OUR QUERY WILL GET THE LAST ONE WITH SAME ID.
6685
+ ctx->MouseMoveToPos (p);
6686
+ ctx->MouseClick ();
6687
+ ctx->MouseMoveToPos (p + field_offset * 1 );
6688
+ ctx->MouseClick ();
6689
+ ctx->MouseMoveToPos (p + field_offset * 2 );
6690
+ ctx->MouseClick ();
6691
+ ctx->MouseDoubleClick (); // Normally we'd use ItemInputvalue() but because of the IDconflict this is simplier
6692
+ ctx->KeyCharsReplaceEnter (" 1234" );
6693
+ }
6694
+ ctx->CaptureEndVideo ();
6695
+ };
6696
+
6624
6697
// ## Capture all tables demo
6625
6698
t = IM_REGISTER_TEST (e, " capture" , " capture_table_demo" );
6626
6699
t->TestFunc = [](ImGuiTestContext* ctx)
0 commit comments