Note that shortcuts are currently provided for display only (future version will add explicit flags to BeginMenu() to request processing shortcuts)
| 6467 | // Note that shortcuts are currently provided for display only |
| 6468 | // (future version will add explicit flags to BeginMenu() to request processing shortcuts) |
| 6469 | static void ShowExampleMenuFile() |
| 6470 | { |
| 6471 | IMGUI_DEMO_MARKER("Examples/Menu"); |
| 6472 | ImGui::MenuItem("(demo menu)", NULL, false, false); |
| 6473 | if (ImGui::MenuItem("New")) {} |
| 6474 | if (ImGui::MenuItem("Open", "Ctrl+O")) {} |
| 6475 | if (ImGui::BeginMenu("Open Recent")) |
| 6476 | { |
| 6477 | ImGui::MenuItem("fish_hat.c"); |
| 6478 | ImGui::MenuItem("fish_hat.inl"); |
| 6479 | ImGui::MenuItem("fish_hat.h"); |
| 6480 | if (ImGui::BeginMenu("More..")) |
| 6481 | { |
| 6482 | ImGui::MenuItem("Hello"); |
| 6483 | ImGui::MenuItem("Sailor"); |
| 6484 | if (ImGui::BeginMenu("Recurse..")) |
| 6485 | { |
| 6486 | ShowExampleMenuFile(); |
| 6487 | ImGui::EndMenu(); |
| 6488 | } |
| 6489 | ImGui::EndMenu(); |
| 6490 | } |
| 6491 | ImGui::EndMenu(); |
| 6492 | } |
| 6493 | if (ImGui::MenuItem("Save", "Ctrl+S")) {} |
| 6494 | if (ImGui::MenuItem("Save As..")) {} |
| 6495 | |
| 6496 | ImGui::Separator(); |
| 6497 | IMGUI_DEMO_MARKER("Examples/Menu/Options"); |
| 6498 | if (ImGui::BeginMenu("Options")) |
| 6499 | { |
| 6500 | static bool enabled = true; |
| 6501 | ImGui::MenuItem("Enabled", "", &enabled); |
| 6502 | ImGui::BeginChild("child", ImVec2(0, 60), true); |
| 6503 | for (int i = 0; i < 10; i++) |
| 6504 | ImGui::Text("Scrolling Text %d", i); |
| 6505 | ImGui::EndChild(); |
| 6506 | static float f = 0.5f; |
| 6507 | static int n = 0; |
| 6508 | ImGui::SliderFloat("Value", &f, 0.0f, 1.0f); |
| 6509 | ImGui::InputFloat("Input", &f, 0.1f); |
| 6510 | ImGui::Combo("Combo", &n, "Yes\0No\0Maybe\0\0"); |
| 6511 | ImGui::EndMenu(); |
| 6512 | } |
| 6513 | |
| 6514 | IMGUI_DEMO_MARKER("Examples/Menu/Colors"); |
| 6515 | if (ImGui::BeginMenu("Colors")) |
| 6516 | { |
| 6517 | float sz = ImGui::GetTextLineHeight(); |
| 6518 | for (int i = 0; i < ImGuiCol_COUNT; i++) |
| 6519 | { |
| 6520 | const char* name = ImGui::GetStyleColorName((ImGuiCol)i); |
| 6521 | ImVec2 p = ImGui::GetCursorScreenPos(); |
| 6522 | ImGui::GetWindowDrawList()->AddRectFilled(p, ImVec2(p.x + sz, p.y + sz), ImGui::GetColorU32((ImGuiCol)i)); |
| 6523 | ImGui::Dummy(ImVec2(sz, sz)); |
| 6524 | ImGui::SameLine(); |
| 6525 | ImGui::MenuItem(name); |
| 6526 | } |
no test coverage detected