Note that shortcuts are currently provided for display only (future version will add explicit flags to BeginMenu() to request processing shortcuts)
| 6645 | // Note that shortcuts are currently provided for display only |
| 6646 | // (future version will add explicit flags to BeginMenu() to request processing shortcuts) |
| 6647 | static void ShowExampleMenuFile() |
| 6648 | { |
| 6649 | IMGUI_DEMO_MARKER("Examples/Menu"); |
| 6650 | ImGui::MenuItem("(demo menu)", NULL, false, false); |
| 6651 | if (ImGui::MenuItem("New")) {} |
| 6652 | if (ImGui::MenuItem("Open", "Ctrl+O")) {} |
| 6653 | if (ImGui::BeginMenu("Open Recent")) |
| 6654 | { |
| 6655 | ImGui::MenuItem("fish_hat.c"); |
| 6656 | ImGui::MenuItem("fish_hat.inl"); |
| 6657 | ImGui::MenuItem("fish_hat.h"); |
| 6658 | if (ImGui::BeginMenu("More..")) |
| 6659 | { |
| 6660 | ImGui::MenuItem("Hello"); |
| 6661 | ImGui::MenuItem("Sailor"); |
| 6662 | if (ImGui::BeginMenu("Recurse..")) |
| 6663 | { |
| 6664 | ShowExampleMenuFile(); |
| 6665 | ImGui::EndMenu(); |
| 6666 | } |
| 6667 | ImGui::EndMenu(); |
| 6668 | } |
| 6669 | ImGui::EndMenu(); |
| 6670 | } |
| 6671 | if (ImGui::MenuItem("Save", "Ctrl+S")) {} |
| 6672 | if (ImGui::MenuItem("Save As..")) {} |
| 6673 | |
| 6674 | ImGui::Separator(); |
| 6675 | IMGUI_DEMO_MARKER("Examples/Menu/Options"); |
| 6676 | if (ImGui::BeginMenu("Options")) |
| 6677 | { |
| 6678 | static bool enabled = true; |
| 6679 | ImGui::MenuItem("Enabled", "", &enabled); |
| 6680 | ImGui::BeginChild("child", ImVec2(0, 60), true); |
| 6681 | for (int i = 0; i < 10; i++) |
| 6682 | ImGui::Text("Scrolling Text %d", i); |
| 6683 | ImGui::EndChild(); |
| 6684 | static float f = 0.5f; |
| 6685 | static int n = 0; |
| 6686 | ImGui::SliderFloat("Value", &f, 0.0f, 1.0f); |
| 6687 | ImGui::InputFloat("Input", &f, 0.1f); |
| 6688 | ImGui::Combo("Combo", &n, "Yes\0No\0Maybe\0\0"); |
| 6689 | ImGui::EndMenu(); |
| 6690 | } |
| 6691 | |
| 6692 | IMGUI_DEMO_MARKER("Examples/Menu/Colors"); |
| 6693 | if (ImGui::BeginMenu("Colors")) |
| 6694 | { |
| 6695 | float sz = ImGui::GetTextLineHeight(); |
| 6696 | for (int i = 0; i < ImGuiCol_COUNT; i++) |
| 6697 | { |
| 6698 | const char* name = ImGui::GetStyleColorName((ImGuiCol)i); |
| 6699 | ImVec2 p = ImGui::GetCursorScreenPos(); |
| 6700 | ImGui::GetWindowDrawList()->AddRectFilled(p, ImVec2(p.x + sz, p.y + sz), ImGui::GetColorU32((ImGuiCol)i)); |
| 6701 | ImGui::Dummy(ImVec2(sz, sz)); |
| 6702 | ImGui::SameLine(); |
| 6703 | ImGui::MenuItem(name); |
| 6704 | } |
no test coverage detected