Note that shortcuts are currently provided for display only (future version will add explicit flags to BeginMenu() to request processing shortcuts)
| 8673 | // Note that shortcuts are currently provided for display only |
| 8674 | // (future version will add explicit flags to BeginMenu() to request processing shortcuts) |
| 8675 | static void ShowExampleMenuFile() |
| 8676 | { |
| 8677 | IMGUI_DEMO_MARKER("Examples/Menu"); |
| 8678 | ImGui::MenuItem("(demo menu)", NULL, false, false); |
| 8679 | if (ImGui::MenuItem("New")) {} |
| 8680 | if (ImGui::MenuItem("Open", "Ctrl+O")) {} |
| 8681 | if (ImGui::BeginMenu("Open Recent")) |
| 8682 | { |
| 8683 | ImGui::MenuItem("fish_hat.c"); |
| 8684 | ImGui::MenuItem("fish_hat.inl"); |
| 8685 | ImGui::MenuItem("fish_hat.h"); |
| 8686 | if (ImGui::BeginMenu("More..")) |
| 8687 | { |
| 8688 | ImGui::MenuItem("Hello"); |
| 8689 | ImGui::MenuItem("Sailor"); |
| 8690 | if (ImGui::BeginMenu("Recurse..")) |
| 8691 | { |
| 8692 | ShowExampleMenuFile(); |
| 8693 | ImGui::EndMenu(); |
| 8694 | } |
| 8695 | ImGui::EndMenu(); |
| 8696 | } |
| 8697 | ImGui::EndMenu(); |
| 8698 | } |
| 8699 | if (ImGui::MenuItem("Save", "Ctrl+S")) {} |
| 8700 | if (ImGui::MenuItem("Save As..")) {} |
| 8701 | |
| 8702 | ImGui::Separator(); |
| 8703 | IMGUI_DEMO_MARKER("Examples/Menu/Options"); |
| 8704 | if (ImGui::BeginMenu("Options")) |
| 8705 | { |
| 8706 | static bool enabled = true; |
| 8707 | ImGui::MenuItem("Enabled", "", &enabled); |
| 8708 | ImGui::BeginChild("child", ImVec2(0, 60), ImGuiChildFlags_Borders); |
| 8709 | for (int i = 0; i < 10; i++) |
| 8710 | ImGui::Text("Scrolling Text %d", i); |
| 8711 | ImGui::EndChild(); |
| 8712 | static float f = 0.5f; |
| 8713 | static int n = 0; |
| 8714 | ImGui::SliderFloat("Value", &f, 0.0f, 1.0f); |
| 8715 | ImGui::InputFloat("Input", &f, 0.1f); |
| 8716 | ImGui::Combo("Combo", &n, "Yes\0No\0Maybe\0\0"); |
| 8717 | ImGui::EndMenu(); |
| 8718 | } |
| 8719 | |
| 8720 | IMGUI_DEMO_MARKER("Examples/Menu/Colors"); |
| 8721 | if (ImGui::BeginMenu("Colors")) |
| 8722 | { |
| 8723 | float sz = ImGui::GetTextLineHeight(); |
| 8724 | for (int i = 0; i < ImGuiCol_COUNT; i++) |
| 8725 | { |
| 8726 | const char* name = ImGui::GetStyleColorName((ImGuiCol)i); |
| 8727 | ImVec2 p = ImGui::GetCursorScreenPos(); |
| 8728 | ImGui::GetWindowDrawList()->AddRectFilled(p, ImVec2(p.x + sz, p.y + sz), ImGui::GetColorU32((ImGuiCol)i)); |
| 8729 | ImGui::Dummy(ImVec2(sz, sz)); |
| 8730 | ImGui::SameLine(); |
| 8731 | ImGui::MenuItem(name); |
| 8732 | } |
no test coverage detected