| 606 | } |
| 607 | |
| 608 | static void createWorkspaceMenu() { |
| 609 | ContentRegistry::UserInterface::registerMainMenuItem("hex.builtin.menu.workspace", 4000); |
| 610 | |
| 611 | createLayoutMenu(); |
| 612 | |
| 613 | ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.workspace" }, 3000); |
| 614 | |
| 615 | ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.workspace", "hex.builtin.menu.workspace.create" }, ICON_VS_ADD, 3100, Shortcut::None, [] { |
| 616 | ui::PopupTextInput::open("hex.builtin.popup.create_workspace.title", "hex.builtin.popup.create_workspace.desc", [](const std::string &name) { |
| 617 | WorkspaceManager::createWorkspace(name); |
| 618 | }); |
| 619 | }, ImHexApi::Provider::isValid); |
| 620 | |
| 621 | ContentRegistry::UserInterface::addMenuItemSubMenu({ "hex.builtin.menu.workspace" }, 3200, [] { |
| 622 | const auto &workspaces = WorkspaceManager::getWorkspaces(); |
| 623 | |
| 624 | bool shiftPressed = ImGui::GetIO().KeyShift; |
| 625 | for (auto it = workspaces.begin(); it != workspaces.end(); ++it) { |
| 626 | const auto &[name, workspace] = *it; |
| 627 | |
| 628 | bool canRemove = shiftPressed && !workspace.builtin; |
| 629 | if (menu::menuItem(fmt::format("{}{}", name, canRemove ? " " ICON_VS_CHROME_CLOSE : "").c_str(), Shortcut::None, it == WorkspaceManager::getCurrentWorkspace(), ImHexApi::Provider::isValid())) { |
| 630 | if (canRemove) { |
| 631 | WorkspaceManager::removeWorkspace(name); |
| 632 | break; |
| 633 | } else { |
| 634 | WorkspaceManager::switchWorkspace(name); |
| 635 | } |
| 636 | } |
| 637 | } |
| 638 | }); |
| 639 | } |
| 640 | |
| 641 | static void createExtrasMenu() { |
| 642 | ContentRegistry::UserInterface::registerMainMenuItem("hex.builtin.menu.extras", 5000); |
no test coverage detected