From a3c393b4b163c2da954064721825a2371a8ea32f Mon Sep 17 00:00:00 2001
From: Patrick Wuttke
Date: Tue, 17 Feb 2026 10:37:23 +0100
Subject: [PATCH] Added first version of the task list component.
---
public/raid/components/task_list.hpp | 78 ++++++++++++++++++++++++++++
1 file changed, 78 insertions(+)
create mode 100644 public/raid/components/task_list.hpp
diff --git a/public/raid/components/task_list.hpp b/public/raid/components/task_list.hpp
new file mode 100644
index 0000000..b107046
--- /dev/null
+++ b/public/raid/components/task_list.hpp
@@ -0,0 +1,78 @@
+
+#pragma once
+
+#if !defined(RAID_PUBLIC_RAID_COMPONENTS_TASK_LIST_HPP_INCLUDED)
+#define RAID_PUBLIC_RAID_COMPONENTS_TASK_LIST_HPP_INCLUDED 1
+
+#include
+#include "../imraid.hpp"
+#include "../imutil.hpp"
+#include "../raid.hpp"
+
+#include
+#include
+
+namespace ImRaid
+{
+template typename TAllocator, typename TPrintFunc>
+void RenderTaskList(const char* strID, mijin::BaseSimpleTaskLoop& loop, TPrintFunc printFunc)
+{
+ if (!ImGui::BeginTable(strID, 3)) {
+ return;
+ }
+ ImGui::TableSetupColumn("Name");
+ ImGui::TableSetupColumn("State");
+
+ ImGui::TableHeadersRow();
+
+ for (const mijin::TaskHandle& handle : loop.getAllTasks())
+ {
+ if (!handle.isValid()) {
+ continue;
+ }
+ IDScope scope(handle.getState());
+
+ ImGui::TableNextRow();
+ const mijin::Optional location = handle.getLocation();
+ location.then(
+ /* success = */ [](std::source_location loc) {
+ ImGui::Text("%s [%s:%" PRIuLEAST32 "]", loc.function_name(), loc.file_name(), loc.line());
+ },
+ /* error = */ []() {
+ ImGui::TextUnformatted("???");
+ }
+ );
+ ImGui::TableNextColumn();
+ ImGui::TextUnformatted("TBD");
+
+ ImGui::TableNextColumn();
+ if (ImGui::SmallButton(ICON_FA_LIST))
+ {
+ mijin::Optional> stackOpt = handle.getLocationStack();
+ stackOpt.then(
+ /* success = */ [&](const std::vector& stack) {
+ for (std::source_location loc : stack) {
+ std::invoke(printFunc, raid::formatTemp("{} [{}:{}]", loc.function_name(), loc.file_name(), loc.line()));
+ }
+ },
+ /* error = */ [&]() {
+ std::invoke(printFunc, "Could not capture stack.");
+ }
+ );
+ }
+ ImGui::SetItemTooltip("Dump callstack");
+ }
+ ImGui::EndTable();
+}
+
+template typename TAllocator, typename TPrintFunc>
+void ShowTaskListWindow(const char* name, bool* open, mijin::BaseSimpleTaskLoop& loop, TPrintFunc printFunc)
+{
+ if (ImGui::Begin(name, open)) {
+ RenderTaskList("##tasks", loop, std::move(printFunc));
+ }
+ ImGui::End();
+}
+} // namespace ImRaid
+
+#endif // !defined(RAID_PUBLIC_RAID_COMPONENTS_TASK_LIST_HPP_INCLUDED)