Note that shortcuts are currently provided for display only (future version will add explicit flags to BeginMenu() to request processing shortcuts)
| 8795 | // Note that shortcuts are currently provided for display only |
| 8796 | // (future version will add explicit flags to BeginMenu() to request processing shortcuts) |
| 8797 | static void ShowExampleMenuFile() |
| 8798 | { |
| 8799 | IMGUI_DEMO_MARKER("Examples/Menu"); |
| 8800 | ImGui::MenuItem("(demo menu)", NULL, false, false); |
| 8801 | if (ImGui::MenuItem("New")) {} |
| 8802 | if (ImGui::MenuItem("Open", "Ctrl+O")) {} |
| 8803 | if (ImGui::BeginMenu("Open Recent")) |
| 8804 | { |
| 8805 | ImGui::MenuItem("fish_hat.c"); |
| 8806 | ImGui::MenuItem("fish_hat.inl"); |
| 8807 | ImGui::MenuItem("fish_hat.h"); |
| 8808 | if (ImGui::BeginMenu("More..")) |
| 8809 | { |
| 8810 | ImGui::MenuItem("Hello"); |
| 8811 | ImGui::MenuItem("Sailor"); |
| 8812 | if (ImGui::BeginMenu("Recurse..")) |
| 8813 | { |
| 8814 | ShowExampleMenuFile(); |
| 8815 | ImGui::EndMenu(); |
| 8816 | } |
| 8817 | ImGui::EndMenu(); |
| 8818 | } |
| 8819 | ImGui::EndMenu(); |
| 8820 | } |
| 8821 | if (ImGui::MenuItem("Save", "Ctrl+S")) {} |
| 8822 | if (ImGui::MenuItem("Save As..")) {} |
| 8823 | |
| 8824 | ImGui::Separator(); |
| 8825 | if (ImGui::BeginMenu("Options")) |
| 8826 | { |
| 8827 | IMGUI_DEMO_MARKER("Examples/Menu/Options"); |
| 8828 | static bool enabled = true; |
| 8829 | ImGui::MenuItem("Enabled", "", &enabled); |
| 8830 | ImGui::BeginChild("child", ImVec2(0, 60), ImGuiChildFlags_Borders); |
| 8831 | for (int i = 0; i < 10; i++) |
| 8832 | ImGui::Text("Scrolling Text %d", i); |
| 8833 | ImGui::EndChild(); |
| 8834 | static float f = 0.5f; |
| 8835 | static int n = 0; |
| 8836 | ImGui::SliderFloat("Value", &f, 0.0f, 1.0f); |
| 8837 | ImGui::InputFloat("Input", &f, 0.1f); |
| 8838 | ImGui::Combo("Combo", &n, "Yes\0No\0Maybe\0\0"); |
| 8839 | ImGui::EndMenu(); |
| 8840 | } |
| 8841 | |
| 8842 | if (ImGui::BeginMenu("Colors")) |
| 8843 | { |
| 8844 | IMGUI_DEMO_MARKER("Examples/Menu/Colors"); |
| 8845 | float sz = ImGui::GetTextLineHeight(); |
| 8846 | for (int i = 0; i < ImGuiCol_COUNT; i++) |
| 8847 | { |
| 8848 | const char* name = ImGui::GetStyleColorName((ImGuiCol)i); |
| 8849 | ImVec2 p = ImGui::GetCursorScreenPos(); |
| 8850 | ImGui::GetWindowDrawList()->AddRectFilled(p, ImVec2(p.x + sz, p.y + sz), ImGui::GetColorU32((ImGuiCol)i)); |
| 8851 | ImGui::Dummy(ImVec2(sz, sz)); |
| 8852 | ImGui::SameLine(); |
| 8853 | ImGui::MenuItem(name); |
| 8854 | } |
no test coverage detected