Note that shortcuts are currently provided for display only (future version will add explicit flags to BeginMenu() to request processing shortcuts)
| 8871 | // Note that shortcuts are currently provided for display only |
| 8872 | // (future version will add explicit flags to BeginMenu() to request processing shortcuts) |
| 8873 | static void ShowExampleMenuFile() |
| 8874 | { |
| 8875 | IMGUI_DEMO_MARKER("Examples/Menu"); |
| 8876 | ImGui::MenuItem("(demo menu)", NULL, false, false); |
| 8877 | if (ImGui::MenuItem("New")) {} |
| 8878 | if (ImGui::MenuItem("Open", "Ctrl+O")) {} |
| 8879 | if (ImGui::BeginMenu("Open Recent")) |
| 8880 | { |
| 8881 | ImGui::MenuItem("fish_hat.c"); |
| 8882 | ImGui::MenuItem("fish_hat.inl"); |
| 8883 | ImGui::MenuItem("fish_hat.h"); |
| 8884 | if (ImGui::BeginMenu("More..")) |
| 8885 | { |
| 8886 | ImGui::MenuItem("Hello"); |
| 8887 | ImGui::MenuItem("Sailor"); |
| 8888 | if (ImGui::BeginMenu("Recurse..")) |
| 8889 | { |
| 8890 | ShowExampleMenuFile(); |
| 8891 | ImGui::EndMenu(); |
| 8892 | } |
| 8893 | ImGui::EndMenu(); |
| 8894 | } |
| 8895 | ImGui::EndMenu(); |
| 8896 | } |
| 8897 | if (ImGui::MenuItem("Save", "Ctrl+S")) {} |
| 8898 | if (ImGui::MenuItem("Save As..")) {} |
| 8899 | |
| 8900 | ImGui::Separator(); |
| 8901 | if (ImGui::BeginMenu("Options")) |
| 8902 | { |
| 8903 | IMGUI_DEMO_MARKER("Examples/Menu/Options"); |
| 8904 | static bool enabled = true; |
| 8905 | ImGui::MenuItem("Enabled", "", &enabled); |
| 8906 | ImGui::BeginChild("child", ImVec2(0, ImGui::GetTextLineHeightWithSpacing() * 5.0f), ImGuiChildFlags_Borders); |
| 8907 | for (int i = 0; i < 10; i++) |
| 8908 | ImGui::Text("Scrolling Text %d", i); |
| 8909 | ImGui::EndChild(); |
| 8910 | static float f = 0.5f; |
| 8911 | static int n = 0; |
| 8912 | ImGui::SliderFloat("Value", &f, 0.0f, 1.0f); |
| 8913 | ImGui::InputFloat("Input", &f, 0.1f); |
| 8914 | ImGui::Combo("Combo", &n, "Yes\0No\0Maybe\0\0"); |
| 8915 | ImGui::EndMenu(); |
| 8916 | } |
| 8917 | |
| 8918 | if (ImGui::BeginMenu("Colors")) |
| 8919 | { |
| 8920 | IMGUI_DEMO_MARKER("Examples/Menu/Colors"); |
| 8921 | float sz = ImGui::GetTextLineHeight(); |
| 8922 | for (int i = 0; i < ImGuiCol_COUNT; i++) |
| 8923 | { |
| 8924 | const char* name = ImGui::GetStyleColorName((ImGuiCol)i); |
| 8925 | ImVec2 p = ImGui::GetCursorScreenPos(); |
| 8926 | ImGui::GetWindowDrawList()->AddRectFilled(p, ImVec2(p.x + sz, p.y + sz), ImGui::GetColorU32((ImGuiCol)i)); |
| 8927 | ImGui::Dummy(ImVec2(sz, sz)); |
| 8928 | ImGui::SameLine(); |
| 8929 | ImGui::MenuItem(name); |
| 8930 | } |
no test coverage detected