MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / createViewMenu

Function createViewMenu

src/gui2/imhex_overrides/main_menu_items.cpp:512–564  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

510 }
511
512 static void createViewMenu() {
513 ContentRegistry::UserInterface::registerMainMenuItem("hex.builtin.menu.view", 3000);
514
515 #if !defined(OS_WEB)
516 ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.view", "hex.builtin.menu.view.always_on_top" }, ICON_VS_PINNED, 1000, Keys::F10 + AllowWhileTyping, [] {
517 static bool state = false;
518
519 state = !state;
520 glfwSetWindowAttrib(ImHexApi::System::getMainWindowHandle(), GLFW_FLOATING, state);
521 }, []{ return true; }, []{ return glfwGetWindowAttrib(ImHexApi::System::getMainWindowHandle(), GLFW_FLOATING); });
522 #endif
523
524 #if !defined(OS_MACOS) && !defined(OS_WEB)
525 ContentRegistry::UserInterface::addMenuItem({ "hex.builtin.menu.view", "hex.builtin.menu.view.fullscreen" }, ICON_VS_SCREEN_FULL, 2000, Keys::F11 + AllowWhileTyping, [] {
526 static bool state = false;
527 static ImVec2 position, size;
528
529 state = !state;
530
531
532 const auto window = ImHexApi::System::getMainWindowHandle();
533 if (state) {
534 position = ImHexApi::System::getMainWindowPosition();
535 size = ImHexApi::System::getMainWindowSize();
536
537 const auto monitor = glfwGetPrimaryMonitor();
538 const auto videoMode = glfwGetVideoMode(monitor);
539
540 glfwSetWindowMonitor(window, monitor, 0, 0, videoMode->width, videoMode->height, videoMode->refreshRate);
541 } else {
542 glfwSetWindowMonitor(window, nullptr, position.x, position.y, size.x, size.y, 0);
543 glfwSetWindowAttrib(window, GLFW_DECORATED, ImHexApi::System::isBorderlessWindowModeEnabled() ? GLFW_FALSE : GLFW_TRUE);
544 }
545
546 }, []{ return true; }, []{ return glfwGetWindowMonitor(ImHexApi::System::getMainWindowHandle()) != nullptr; });
547 #endif
548
549 #if !defined(OS_WEB)
550 ContentRegistry::UserInterface::addMenuItemSeparator({ "hex.builtin.menu.view" }, 3000);
551 #endif
552
553 ContentRegistry::UserInterface::addMenuItemSubMenu({ "hex.builtin.menu.view" }, 4000, [] {
554 for (auto &[name, view] : ContentRegistry::Views::impl::getEntries()) {
555 if (view->hasViewMenuItemEntry()) {
556 auto &state = view->getWindowOpenState();
557
558 if (menu::menuItemEx(Lang(view->getUnlocalizedName()), view->getIcon(), Shortcut::None, state, ImHexApi::Provider::isValid() && !LayoutManager::isLayoutLocked()))
559 state = !state;
560 }
561 }
562 });
563
564 }
565
566 static void createLayoutMenu() {
567 LayoutManager::reload();

Callers 1

registerMainMenuEntriesFunction · 0.85

Calls 3

menuItemExFunction · 0.85
getIconMethod · 0.80
hasViewMenuItemEntryMethod · 0.45

Tested by

no test coverage detected