gui: settings_dialog/debug: Add "Select all" toggle for Tracy modules list

This commit is contained in:
bookmist
2026-02-21 18:12:08 +03:00
parent f52f6e0899
commit ad481fd0f7
+35 -1
View File
@@ -46,6 +46,7 @@
#include <SDL3/SDL_camera.h>
#include <algorithm>
#include <camera/state.h>
#include <imgui_internal.h>
#include <pugixml.hpp>
#include <util/vector_utils.h>
@@ -1499,9 +1500,9 @@ void draw_settings_dialog(GuiState &gui, EmuEnvState &emuenv) {
"be manually instrumented in source code.";
// Tracy modules list
static std::vector<std::string> tracy_modules = tracy_module_utils::get_available_module_names();
if (ImGui::BeginListBox(tracy_modules_list_label, { 0.0f, ImGui::GetTextLineHeightWithSpacing() * 8.25f + ImGui::GetStyle().FramePadding.y * 2.0f })) {
// Get all HLE modules available for advanced profiling using Tracy. Do it only once.
static std::vector<std::string> tracy_modules = tracy_module_utils::get_available_module_names();
// For every HLE module available for advanced profiling using Tracy
for (auto &module : tracy_modules) {
bool activation_state = tracy_module_utils::is_tracy_active(module);
@@ -1523,6 +1524,39 @@ void draw_settings_dialog(GuiState &gui, EmuEnvState &emuenv) {
}
ImGui::EndListBox();
}
// Calculate checkbox state based on Tracy modules selection
int selected_count = 0;
int visible_count = static_cast<int>(tracy_modules.size());
for (const auto &module : tracy_modules) {
if (tracy_module_utils::is_tracy_active(module))
selected_count++;
}
bool all_selected = selected_count == visible_count;
bool partial_selected = (selected_count > 0) && (selected_count < visible_count);
// Set checkbox appearance based on state (indeterminate when partially selected)
if (partial_selected) {
ImGui::PushItemFlag(ImGuiItemFlags_MixedValue, true);
}
static bool selection_state = all_selected || partial_selected;
if (ImGui::Checkbox("Select all##tracy", &selection_state)) {
// Toggle all tracy modules
for (const auto &module : tracy_modules) {
tracy_module_utils::set_tracy_active(module, selection_state);
const bool module_existed = vector_utils::contains(emuenv.cfg.tracy_advanced_profiling_modules, module);
if (selection_state && !module_existed) {
emuenv.cfg.tracy_advanced_profiling_modules.push_back(module);
} else if (!selection_state && module_existed) {
std::erase(emuenv.cfg.tracy_advanced_profiling_modules, module);
}
}
}
if (partial_selected) {
ImGui::PopItemFlag();
}
#endif // TRACY_ENABLE
ImGui::EndTabItem();