Skip to content

Commit

Permalink
TestSuite: added 'widgets_disabled_nested"
Browse files Browse the repository at this point in the history
  • Loading branch information
ocornut committed May 31, 2024
1 parent 73a1806 commit ac5b5ed
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
3 changes: 3 additions & 0 deletions imgui_test_suite/imgui_tests_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3714,6 +3714,9 @@ void RegisterTests_Misc(ImGuiTestEngine* e)
ImGui::BeginGroup();
#ifdef IMGUI_HAS_MULTI_SELECT
ImGui::BeginMultiSelect(ImGuiMultiSelectFlags_None);
#endif
#if IMGUI_VERSION_NUM >= 18415
ImGui::BeginDisabled();
#endif
ImGui::SetNextItemOpen(true);
ImGui::TreeNode("node");
Expand Down
42 changes: 41 additions & 1 deletion imgui_test_suite/imgui_tests_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5451,7 +5451,7 @@ void RegisterTests_Widgets(ImGuiTestEngine* e)
#endif

// ## Test BeginDisabled()/EndDisabled()
#if (IMGUI_VERSION_NUM >= 18405)
#if IMGUI_VERSION_NUM >= 18405
t = IM_REGISTER_TEST(e, "widgets", "widgets_disabled_2");
struct BeginDisabledVars
{
Expand Down Expand Up @@ -5541,6 +5541,46 @@ void RegisterTests_Widgets(ImGuiTestEngine* e)
};
#endif

#if IMGUI_VERSION_NUM >= 19073
// ## Test nested functions and Alpha values
t = IM_REGISTER_TEST(e, "widgets", "widgets_disabled_nested");
t->GuiFunc = [](ImGuiTestContext* ctx)
{
ImGuiContext& g = *GImGui;
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 1.0f);
ImGui::PushStyleVar(ImGuiStyleVar_DisabledAlpha, 0.4f);
ImGui::Begin("Test Window", NULL, ImGuiWindowFlags_NoSavedSettings);

ImGui::BeginDisabled();
IM_CHECK((g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0);
IM_CHECK_FLOAT_EQ_EPS(ImGui::GetStyle().Alpha, 1.0f * 0.4f);

ImGui::Begin("Nested window call");
IM_CHECK((g.CurrentItemFlags& ImGuiItemFlags_Disabled) == 0);
IM_CHECK_FLOAT_EQ_EPS(ImGui::GetStyle().Alpha, 1.0f);

ImGui::End();
IM_CHECK((g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0);
IM_CHECK_FLOAT_EQ_EPS(ImGui::GetStyle().Alpha, 1.0f * 0.4f);

ImGui::BeginChild("Nested Child", ImVec2(200, 200));
IM_CHECK((g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0);
IM_CHECK_FLOAT_EQ_EPS(ImGui::GetStyle().Alpha, 1.0f * 0.4f);

ImGui::EndChild();
IM_CHECK((g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0);
IM_CHECK_FLOAT_EQ_EPS(ImGui::GetStyle().Alpha, 1.0f * 0.4f);

ImGui::EndDisabled();
IM_CHECK((g.CurrentItemFlags & ImGuiItemFlags_Disabled) == 0);
IM_CHECK_FLOAT_EQ_EPS(ImGui::GetStyle().Alpha, 1.0f);

ImGui::End();
ImGui::PopStyleVar();
ImGui::PopStyleVar();
};
#endif

// ## Test SetItemUsingMouseWheel() preventing scrolling.
t = IM_REGISTER_TEST(e, "widgets", "widgets_item_using_mouse_wheel");
t->GuiFunc = [](ImGuiTestContext* ctx)
Expand Down

0 comments on commit ac5b5ed

Please sign in to comment.