1#ifndef YAZE_APP_EDITOR_ORACLE_PANELS_ANNOTATION_OVERLAY_PANEL_H
2#define YAZE_APP_EDITOR_ORACLE_PANELS_ANNOTATION_OVERLAY_PANEL_H
15#include "imgui/imgui.h"
16#include "nlohmann/json.hpp"
32struct AnnotationEntry {
53class AnnotationOverlayPanel :
public WindowContent {
55 std::string
GetId()
const override {
return "oracle.annotations"; }
61 return "Review and edit room-level project annotations";
72 void Draw(
bool* )
override {
76 if (!project->code_folder.empty()) {
77 namespace fs = std::filesystem;
79 fs::path(project->GetAbsolutePath(project->code_folder)) /
80 "Docs" /
"Dev" /
"Planning" /
"annotations.json";
87 ImGui::Text(
"Room filter:");
94 const char* priorities[] = {
"All",
"Note",
"Bug",
"Blocker"};
100 ImGui::BeginChild(
"annotation_list", ImVec2(0, -120),
101 ImGuiChildFlags_Borders);
113 ImVec2 cursor = ImGui::GetCursorScreenPos();
114 ImGui::GetWindowDrawList()->AddCircleFilled(
115 ImVec2(cursor.x + 6, cursor.y + 10), 5.0f, dot_color);
116 ImGui::Dummy(ImVec2(16, 0));
120 snprintf(label,
sizeof(label),
"Room 0x%02X: %s##ann_%zu", ann.room_id,
121 ann.text.c_str(), i);
123 if (ImGui::Selectable(label,
selected_index_ ==
static_cast<int>(i))) {
130 ann.category.c_str());
139 ImGui::Text(
"Room:");
141 ImGui::SetNextItemWidth(80);
145 ImGui::Text(
"Priority:");
147 ImGui::SetNextItemWidth(80);
148 const char* pri_names[] = {
"Note",
"Bug",
"Blocker"};
154 if (ImGui::Button(
"Add")) {
167 if (ImGui::Button(
"Update")) {
176 if (ImGui::Button(
"Delete")) {
191 std::vector<const AnnotationEntry*> result;
193 if (ann.room_id == room_id) {
194 result.push_back(&ann);
207 if (ann.room_id == room_id) {
208 max_pri = std::max(max_pri,
static_cast<int>(ann.priority));
217 return IM_COL32(220, 50, 50, 255);
219 return IM_COL32(220, 150, 30, 255);
222 return IM_COL32(60, 120, 220, 255);
232 if (!file.is_open())
return;
238 if (root.contains(
"annotations") && root[
"annotations"].is_array()) {
239 for (
const auto& item : root[
"annotations"]) {
241 entry.room_id = item.value(
"room_id", 0);
242 entry.text = item.value(
"text",
"");
245 entry.category = item.value(
"category",
"");
246 entry.created_at = item.value(
"created_at",
"");
259 nlohmann::json arr = nlohmann::json::array();
263 item[
"room_id"] = ann.room_id;
264 item[
"text"] = ann.text;
265 item[
"priority"] =
static_cast<int>(ann.priority);
266 item[
"category"] = ann.category;
267 item[
"created_at"] = ann.created_at;
271 root[
"annotations"] = arr;
274 if (file.is_open()) {
275 file << root.dump(2) << std::endl;
void SetAnnotationsPath(const std::string &path)
void Draw(bool *) override
Draw the panel content.
WindowLifecycle GetWindowLifecycle() const override
Get the lifecycle category for this window.
std::string GetWorkflowGroup() const override
Optional workflow group for hack-centric actions.
std::vector< const AnnotationEntry * > GetAnnotationsForRoom(int room_id) const
Get annotations for a specific room.
int GetMaxPriorityForRoom(int room_id) const
Get the highest priority for a room (for dot color). Returns -1 if no annotations.
std::string GetWorkflowDescription() const override
Optional workflow description for menus/command palette.
std::string GetEditorCategory() const override
Editor category this panel belongs to.
std::vector< AnnotationEntry > annotations_
std::string annotations_path_
static ImU32 GetPriorityColor(AnnotationPriority priority)
std::string GetDisplayName() const override
Human-readable name shown in menus and title bars.
std::string GetId() const override
Unique identifier for this panel.
std::string GetIcon() const override
Material Design icon for this panel.
::yaze::project::YazeProject * current_project()
Get the current project instance.
Editors are the view controllers for the application.
AnnotationPriority
Annotation priority levels.
WindowLifecycle
Defines lifecycle behavior for editor windows.
@ CrossEditor
User can pin to persist across editors.
A room-level annotation entry.
AnnotationPriority priority