diff --git a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp index 44e323c6d..94e4c68f5 100644 --- a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp +++ b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp @@ -882,7 +882,7 @@ namespace ImGuiExt { const bool hasMenuBar = !std::string_view(label).empty(); ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); - if (ImGui::BeginChild(label, size, ImGuiChildFlags_Border | ImGuiChildFlags_AutoResizeY | flags, hasMenuBar ? ImGuiWindowFlags_MenuBar : ImGuiWindowFlags_None)) { + if (ImGui::BeginChild(hex::format("{}##SubWindow", label).c_str(), size, ImGuiChildFlags_Border | ImGuiChildFlags_AutoResizeY | flags, hasMenuBar ? ImGuiWindowFlags_MenuBar : ImGuiWindowFlags_None)) { if (hasMenuBar && ImGui::BeginMenuBar()) { ImGui::TextUnformatted(label); ImGui::EndMenuBar(); diff --git a/plugins/builtin/source/content/views/view_settings.cpp b/plugins/builtin/source/content/views/view_settings.cpp index b5f8cbb8d..b702d304b 100644 --- a/plugins/builtin/source/content/views/view_settings.cpp +++ b/plugins/builtin/source/content/views/view_settings.cpp @@ -6,6 +6,7 @@ #include #include +#include namespace hex::plugin::builtin { @@ -47,57 +48,59 @@ namespace hex::plugin::builtin { // For each category, create a new tab if (ImGui::BeginTabItem(LangEntry(category.unlocalizedName))) { - // Draw the category description - if (!category.unlocalizedDescription.empty()) { - ImGuiExt::TextFormattedWrapped("{}", LangEntry(category.unlocalizedDescription)); - ImGui::NewLine(); - } + if (ImGui::BeginChild("scrolling")) { - // Draw all settings of that category - for (auto &subCategory : category.subCategories) { + // Draw the category description + if (!category.unlocalizedDescription.empty()) { + ImGuiExt::TextFormattedWrapped("{}", LangEntry(category.unlocalizedDescription)); + ImGui::NewLine(); + } - // Skip empty subcategories - if (subCategory.entries.empty()) - continue; + // Draw all settings of that category + for (auto &subCategory : category.subCategories) { - ImGuiExt::BeginSubWindow(LangEntry(subCategory.unlocalizedName)); - { - for (auto &setting : subCategory.entries) { - ImGui::BeginDisabled(!setting.widget->isEnabled()); - ImGui::PushItemWidth(-200_scaled); - bool settingChanged = setting.widget->draw(LangEntry(setting.unlocalizedName)); - ImGui::PopItemWidth(); - ImGui::EndDisabled(); + // Skip empty subcategories + if (subCategory.entries.empty()) + continue; - if (auto tooltip = setting.widget->getTooltip(); tooltip.has_value() && ImGui::IsItemHovered()) - ImGuiExt::InfoTooltip(LangEntry(tooltip.value())); + ImGuiExt::BeginSubWindow(LangEntry(subCategory.unlocalizedName)); + { + for (auto &setting : subCategory.entries) { + ImGui::BeginDisabled(!setting.widget->isEnabled()); + ImGui::PushItemWidth(-200_scaled); + bool settingChanged = setting.widget->draw(LangEntry(setting.unlocalizedName)); + ImGui::PopItemWidth(); + ImGui::EndDisabled(); - auto &widget = setting.widget; + if (auto tooltip = setting.widget->getTooltip(); tooltip.has_value() && ImGui::IsItemHovered()) + ImGuiExt::InfoTooltip(LangEntry(tooltip.value())); - // Handle a setting being changed - if (settingChanged) { - auto newValue = widget->store(); + auto &widget = setting.widget; - // Write new value to settings - ContentRegistry::Settings::write(category.unlocalizedName, setting.unlocalizedName, newValue); + // Handle a setting being changed + if (settingChanged) { + auto newValue = widget->store(); - // Print a debug message - log::debug("Setting [{} / {}]: Value was changed to {}", category.unlocalizedName, setting.unlocalizedName, nlohmann::to_string(newValue)); + // Write new value to settings + ContentRegistry::Settings::write(category.unlocalizedName, setting.unlocalizedName, newValue); - // Signal that the setting was changed - EventManager::post(); - widget->onChanged(); + // Print a debug message + log::debug("Setting [{} / {}]: Value was changed to {}", category.unlocalizedName, setting.unlocalizedName, nlohmann::to_string(newValue)); - // Request a restart if the setting requires it - if (widget->doesRequireRestart()) - this->m_restartRequested = true; + // Signal that the setting was changed + EventManager::post(); + widget->onChanged(); + + // Request a restart if the setting requires it + if (widget->doesRequireRestart()) + this->m_restartRequested = true; + } } } - + ImGuiExt::EndSubWindow(); } - ImGuiExt::EndSubWindow(); - } + ImGui::EndChild(); ImGui::EndTabItem(); }