@@ -191,11 +191,21 @@ static void DrawTestLog(ImGuiTestEngine* e, ImGuiTest* test)
191191 ImGui::PopStyleVar ();
192192}
193193
194- static void HelpTooltip (const char * desc)
194+ #if IMGUI_VERSION_NUM <= 18963
195+ namespace ImGui
195196{
196- if (ImGui::IsItemHovered ())
197- ImGui::SetTooltip (" %s" , desc);
198- }
197+ void SetItemTooltip (const char * fmt, ...)
198+ {
199+ if (ImGui::IsItemHovered ())
200+ {
201+ va_list args;
202+ va_start (args, fmt);
203+ ImGui::SetTooltipV (fmt, args);
204+ va_end (args);
205+ }
206+ }
207+ };
208+ #endif
199209
200210static bool ShowTestGroupFilterTest (ImGuiTestEngine* e, ImGuiTestGroup group, const char * filter, ImGuiTest* test)
201211{
@@ -309,7 +319,7 @@ static void ShowTestGroup(ImGuiTestEngine* e, ImGuiTestGroup group, Str* filter)
309319 ImGui::InputText (" ##filter" , filter);
310320 ImGui::SameLine ();
311321 ImGui::TextDisabled (" (?)" );
312- HelpTooltip (" Query is composed of one or more comma-separated filter terms with optional modifiers.\n "
322+ ImGui::SetItemTooltip (" Query is composed of one or more comma-separated filter terms with optional modifiers.\n "
313323 " Available modifiers:\n "
314324 " - '-' prefix excludes tests matched by the term.\n "
315325 " - '^' prefix anchors term matching to the start of the string.\n "
@@ -318,7 +328,8 @@ static void ShowTestGroup(ImGuiTestEngine* e, ImGuiTestGroup group, Str* filter)
318328 {
319329 ImGui::SameLine ();
320330 ImGui::SetNextItemWidth (perf_stress_factor_width);
321- ImGui::DragInt (" ##PerfStress" , &e->IO .PerfStressAmount , 0 .1f , 1 , 20 , " x%d" ); HelpTooltip (" Increase workload of performance tests (higher means longer run)." ); // FIXME: Move?
331+ ImGui::DragInt (" ##PerfStress" , &e->IO .PerfStressAmount , 0 .1f , 1 , 20 , " x%d" );
332+ ImGui::SetItemTooltip (" Increase workload of performance tests (higher means longer run)." ); // FIXME: Move?
322333 ImGui::SameLine ();
323334 if (ImGui::Button (perflog_label))
324335 {
@@ -390,10 +401,10 @@ static void ShowTestGroup(ImGuiTestEngine* e, ImGuiTestGroup group, Str* filter)
390401 if (test->Status == ImGuiTestStatus_Suspended)
391402 {
392403 // Resume IM_SUSPEND_TESTFUNC
404+ // FIXME: Terrible user experience to have this here.
393405 if (ImGui::Button (" Con###Run" ))
394406 test->Status = ImGuiTestStatus_Running;
395- if (ImGui::IsItemHovered ())
396- ImGui::SetTooltip (" CTRL+Space to continue." );
407+ ImGui::SetItemTooltip (" CTRL+Space to continue." );
397408 if (ImGui::IsKeyPressed (ImGuiKey_Space) && io.KeyCtrl )
398409 test->Status = ImGuiTestStatus_Running;
399410 }
@@ -560,8 +571,7 @@ static void ShowTestGroup(ImGuiTestEngine* e, ImGuiTestGroup group, Str* filter)
560571 // ImVec2 cursor_pos_bkp = ImGui::GetCursorPos();
561572 ImGui::SetCursorPos (status_button_pos);
562573 TestStatusButton (" status" , status_color, false );// e->IO.IsRunningTests);
563- if (ImGui::IsItemHovered ())
564- ImGui::SetTooltip (" Filtered: %d\n - OK: %d\n - Errors: %d" , tests_completed, tests_succeeded, tests_failed);
574+ ImGui::SetItemTooltip (" Filtered: %d\n - OK: %d\n - Errors: %d" , tests_completed, tests_succeeded, tests_failed);
565575 // ImGui::SetCursorPos(cursor_pos_bkp); // Restore cursor position for rendering further widgets
566576 }
567577}
@@ -613,14 +623,16 @@ static void ImGuiTestEngine_ShowLogAndTools(ImGuiTestEngine* engine)
613623
614624 const ImGuiInputTextCallback filter_callback = [](ImGuiInputTextCallbackData* data) { return (data->EventChar == ' ,' || data->EventChar == ' ;' ) ? 1 : 0 ; };
615625 ImGui::InputText (" Branch/Annotation" , engine->IO .GitBranchName , IM_ARRAYSIZE (engine->IO .GitBranchName ), ImGuiInputTextFlags_CallbackCharFilter, filter_callback, NULL );
616- HelpTooltip (" This will be stored in the CSV file for performance tools." );
626+ ImGui::SetItemTooltip (" This will be stored in the CSV file for performance tools." );
617627
618628 ImGui::Separator ();
619629
620630 if (ImGui::TreeNode (" Screen/video capture" ))
621631 {
622- ImGui::Checkbox (" Capture when requested by API" , &engine->IO .ConfigCaptureEnabled ); HelpTooltip (" Enable or disable screen capture API completely." );
623- ImGui::Checkbox (" Capture screen on error" , &engine->IO .ConfigCaptureOnError ); HelpTooltip (" Capture a screenshot on test failure." );
632+ ImGui::Checkbox (" Capture when requested by API" , &engine->IO .ConfigCaptureEnabled );
633+ ImGui::SetItemTooltip (" Enable or disable screen capture API completely." );
634+ ImGui::Checkbox (" Capture screen on error" , &engine->IO .ConfigCaptureOnError );
635+ ImGui::SetItemTooltip (" Capture a screenshot on test failure." );
624636
625637 // Fields modified by in this call will be synced to engine->CaptureContext.
626638 engine->CaptureTool ._ShowEncoderConfigFields (&engine->CaptureContext );
@@ -720,7 +732,7 @@ static void ImGuiTestEngine_ShowTestTool(ImGuiTestEngine* engine, bool* p_open)
720732 engine->IO .ConfigRunSpeed = level;
721733 ImGui::EndCombo ();
722734 }
723- HelpTooltip (
735+ ImGui::SetItemTooltip (
724736 " Running speed\n "
725737 " - Fast: Run tests as fast as possible (no delay/vsync, teleport mouse, etc.).\n "
726738 " - Normal: Run tests at human watchable speed (for debugging).\n "
@@ -729,13 +741,17 @@ static void ImGuiTestEngine_ShowTestTool(ImGuiTestEngine* engine, bool* p_open)
729741 ImGui::SameLine ();
730742 // ImGui::Checkbox("Fast", &engine->IO.ConfigRunFast);
731743 // ImGui::SameLine();
732- ImGui::Checkbox (" Stop" , &engine->IO .ConfigStopOnError ); HelpTooltip (" Stop running tests when hitting an error." );
744+ ImGui::Checkbox (" Stop" , &engine->IO .ConfigStopOnError );
745+ ImGui::SetItemTooltip (" Stop running tests when hitting an error." );
733746 ImGui::SameLine ();
734- ImGui::Checkbox (" DbgBrk" , &engine->IO .ConfigBreakOnError ); HelpTooltip (" Break in debugger when hitting an error." );
747+ ImGui::Checkbox (" DbgBrk" , &engine->IO .ConfigBreakOnError );
748+ ImGui::SetItemTooltip (" Break in debugger when hitting an error." );
735749 ImGui::SameLine ();
736- ImGui::Checkbox (" KeepGUI" , &engine->IO .ConfigKeepGuiFunc ); HelpTooltip (" Keep GUI function running after a test fails, or when a single queued test is finished.\n Hold ESC to abort a running GUI function." );
750+ ImGui::Checkbox (" KeepGUI" , &engine->IO .ConfigKeepGuiFunc );
751+ ImGui::SetItemTooltip (" Keep GUI function running after a test fails, or when a single queued test is finished.\n Hold ESC to abort a running GUI function." );
737752 ImGui::SameLine ();
738- ImGui::Checkbox (" Refocus" , &engine->IO .ConfigTakeFocusBackAfterTests ); HelpTooltip (" Set focus back to Test window after running tests." );
753+ ImGui::Checkbox (" Refocus" , &engine->IO .ConfigTakeFocusBackAfterTests );
754+ ImGui::SetItemTooltip (" Set focus back to Test window after running tests." );
739755 ImGui::SameLine ();
740756 ImGui::SeparatorEx (ImGuiSeparatorFlags_Vertical);
741757 ImGui::SameLine ();
@@ -747,7 +763,7 @@ static void ImGuiTestEngine_ShowTestTool(ImGuiTestEngine* engine, bool* p_open)
747763 engine->IO .ConfigVerboseLevel = engine->IO .ConfigVerboseLevelOnError = level;
748764 ImGui::EndCombo ();
749765 }
750- HelpTooltip (" Verbose level." );
766+ ImGui::SetItemTooltip (" Verbose level." );
751767 // ImGui::PopStyleVar();
752768 ImGui::Separator ();
753769
0 commit comments