Skip to content

Commit

Permalink
fix: Build issues on other platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
WerWolv committed Jan 4, 2025
1 parent d454e4b commit 01188e4
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions plugins/ui/source/ui/menu_items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ namespace hex::menu {
static bool s_useNativeMenuBar = false;
void enableNativeMenuBar(bool enabled) {
#if !defined (OS_MACOS)
return;
std::ignore = enabled;
#else
if (!enabled) {
macosClearMenu();
}
s_useNativeMenuBar = enabled;
#endif

s_useNativeMenuBar = enabled;

if (!enabled) {
macosClearMenu();
}
}

bool isNativeMenuBarUsed() {
Expand All @@ -52,18 +51,22 @@ namespace hex::menu {

return macosBeginMainMenuBar();
}
#else
std::ignore = s_initialized;
#endif

return ImGui::BeginMainMenuBar();
}

void endMainMenuBar() {
#if defined(OS_MACOS)
if (s_useNativeMenuBar)
return macosEndMainMenuBar();
if (s_useNativeMenuBar) {
macosEndMainMenuBar();
return;
}
#endif

return ImGui::EndMainMenuBar();
ImGui::EndMainMenuBar();
}

bool beginMenu(const char *label, bool enabled) {
Expand All @@ -86,11 +89,13 @@ namespace hex::menu {

void endMenu() {
#if defined(OS_MACOS)
if (s_useNativeMenuBar)
return macosEndMenu();
if (s_useNativeMenuBar) {
macosEndMenu();
return;
}
#endif

return ImGui::EndMenu();
ImGui::EndMenu();
}


Expand Down Expand Up @@ -127,17 +132,25 @@ namespace hex::menu {
return macosMenuItemSelect(label, shortcut.toKeyEquivalent(), selected, enabled);
#endif

return ImGui::MenuItemEx(label, icon, shortcut.toString().c_str(), selected, enabled);
if (ImGui::MenuItemEx(label, icon, shortcut.toString().c_str(), selected != nullptr ? *selected : false, enabled)) {
if (selected != nullptr)
*selected = !*selected;
return true;
}

return false;
}


void menuSeparator() {
#if defined(OS_MACOS)
if (s_useNativeMenuBar)
return macosSeparator();
if (s_useNativeMenuBar) {
macosSeparator();
return;
}
#endif

return ImGui::Separator();
ImGui::Separator();
}

}

0 comments on commit 01188e4

Please sign in to comment.