1#ifndef YAZE_APP_EDITOR_ORACLE_PANELS_ANNOTATION_OVERLAY_PANEL_H
2#define YAZE_APP_EDITOR_ORACLE_PANELS_ANNOTATION_OVERLAY_PANEL_H
16#include "imgui/imgui.h"
17#include "nlohmann/json.hpp"
33struct AnnotationEntry {
54class AnnotationOverlayPanel :
public WindowContent {
56 std::string
GetId()
const override {
return "oracle.annotations"; }
65 return "Review and edit room-level project annotations";
76 void Draw(
bool* )
override {
80 if (!project->code_folder.empty()) {
81 namespace fs = std::filesystem;
83 fs::path(project->GetAbsolutePath(project->code_folder)) /
84 "Docs" /
"Dev" /
"Planning" /
"annotations.json";
91 ImGui::Text(tr(
"Room filter:"));
95 if (ImGui::Button(tr(
"All")))
99 const char* priorities[] = {
"All",
"Note",
"Bug",
"Blocker"};
105 ImGui::BeginChild(
"annotation_list", ImVec2(0, -120),
106 ImGuiChildFlags_Borders);
119 ImVec2 cursor = ImGui::GetCursorScreenPos();
120 ImGui::GetWindowDrawList()->AddCircleFilled(
121 ImVec2(cursor.x + 6, cursor.y + 10), 5.0f, dot_color);
122 ImGui::Dummy(ImVec2(16, 0));
126 snprintf(label,
sizeof(label),
"Room 0x%02X: %s##ann_%zu", ann.room_id,
127 ann.text.c_str(), i);
129 if (ImGui::Selectable(label,
selected_index_ ==
static_cast<int>(i))) {
136 ann.category.c_str());
145 ImGui::Text(tr(
"Room:"));
147 ImGui::SetNextItemWidth(80);
151 ImGui::Text(tr(
"Priority:"));
153 ImGui::SetNextItemWidth(80);
154 const char* pri_names[] = {
"Note",
"Bug",
"Blocker"};
160 if (ImGui::Button(tr(
"Add"))) {
173 if (ImGui::Button(tr(
"Update"))) {
182 if (ImGui::Button(tr(
"Delete"))) {
196 std::vector<const AnnotationEntry*> result;
198 if (ann.room_id == room_id) {
199 result.push_back(&ann);
212 if (ann.room_id == room_id) {
213 max_pri = std::max(max_pri,
static_cast<int>(ann.priority));
222 return IM_COL32(220, 50, 50, 255);
224 return IM_COL32(220, 150, 30, 255);
227 return IM_COL32(60, 120, 220, 255);
245 if (root.contains(
"annotations") && root[
"annotations"].is_array()) {
246 for (
const auto& item : root[
"annotations"]) {
248 entry.room_id = item.value(
"room_id", 0);
249 entry.text = item.value(
"text",
"");
252 entry.category = item.value(
"category",
"");
253 entry.created_at = item.value(
"created_at",
"");
267 nlohmann::json arr = nlohmann::json::array();
271 item[
"room_id"] = ann.room_id;
272 item[
"text"] = ann.text;
273 item[
"priority"] =
static_cast<int>(ann.priority);
274 item[
"category"] = ann.category;
275 item[
"created_at"] = ann.created_at;
279 root[
"annotations"] = arr;
282 if (file.is_open()) {
283 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)
WindowPresentationPolicy GetPresentationPolicy() const override
How this content is hosted and advertised by workspace chrome.
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
static WindowPresentationPolicy OptionalPopOut()