yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
project_workflow_output_panel.cc
Go to the documentation of this file.
2
3#include "absl/strings/str_format.h"
6#include "imgui/imgui.h"
7
9
11 (void)p_open;
12
13 const auto build_status = ContentRegistry::Context::build_workflow_status();
14 const auto run_status = ContentRegistry::Context::run_workflow_status();
15 const auto build_log = ContentRegistry::Context::build_workflow_log();
16 const auto history = ContentRegistry::Context::workflow_history();
17 const auto cancel_build =
19
20 if (!build_status.visible && !run_status.visible && build_log.empty() &&
21 history.empty()) {
22 ImGui::TextDisabled("No workflow output available yet.");
23 ImGui::TextWrapped(
24 "Run a project build or output reload to populate workflow status and logs.");
25 return;
26 }
27
28 if (build_status.visible) {
29 DrawStatusCard(ICON_MD_BUILD, build_status);
30 if (build_status.can_cancel && cancel_build) {
31 if (ImGui::Button(ICON_MD_CANCEL " Cancel Build")) {
32 cancel_build();
33 }
34 }
35 ImGui::Spacing();
36 }
37
38 if (run_status.visible) {
40 ImGui::Spacing();
41 }
42
43 if (!build_log.empty()) {
44 ImGui::Separator();
45 ImGui::TextColored(gui::GetTextSecondaryVec4(), "%s Build Output",
47 ImGui::SameLine();
48 DrawCopyCurrentLogButton(build_log);
49 if (ImGui::BeginChild("##workflow_output_log", ImVec2(0, 240), true,
50 ImGuiWindowFlags_HorizontalScrollbar)) {
51 ImGui::TextUnformatted(build_log.c_str());
52 if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) {
53 ImGui::SetScrollHereY(1.0f);
54 }
55 }
56 ImGui::EndChild();
57 }
58
59 if (!history.empty()) {
60 ImGui::Separator();
61 ImGui::TextColored(gui::GetTextSecondaryVec4(), "%s Recent History",
63 ImGui::SameLine();
64 if (ImGui::SmallButton(ICON_MD_DELETE_SWEEP " Clear History")) {
66 }
67 for (size_t i = 0; i < history.size(); ++i) {
68 DrawHistoryEntry(history[i], static_cast<int>(i));
69 }
70 }
71}
72
74 const char* fallback_icon, const ProjectWorkflowStatus& status) {
75 ImGui::TextColored(WorkflowColor(status.state), "%s %s",
76 WorkflowIcon(status, fallback_icon),
77 status.summary.empty() ? status.label.c_str()
78 : status.summary.c_str());
79 if (!status.detail.empty()) {
80 ImGui::TextWrapped("%s", status.detail.c_str());
81 }
82 if (!status.output_tail.empty()) {
83 ImGui::TextWrapped("%s", status.output_tail.c_str());
84 }
85}
86
88 const ProjectWorkflowHistoryEntry& entry, int index) {
89 ImGui::PushID(index);
93 const std::string title = absl::StrFormat(
94 "%s %s - %s", entry.kind.c_str(), entry.status.summary.c_str(),
95 FormatHistoryTime(entry.timestamp).c_str());
96 if (ImGui::CollapsingHeader(title.c_str(), ImGuiTreeNodeFlags_DefaultOpen)) {
98 entry.status);
99 DrawHistoryActionRow(entry, callbacks);
100
101 if (!entry.output_log.empty()) {
102 if (ImGui::BeginChild("##workflow_history_log", ImVec2(0, 120), true,
103 ImGuiWindowFlags_HorizontalScrollbar)) {
104 ImGui::TextUnformatted(entry.output_log.c_str());
105 }
106 ImGui::EndChild();
107 }
108 }
109 ImGui::PopID();
110}
111
112} // namespace yaze::editor::workflow
void DrawStatusCard(const char *fallback_icon, const ProjectWorkflowStatus &status)
void Draw(bool *p_open) override
Draw the panel content.
void DrawHistoryEntry(const ProjectWorkflowHistoryEntry &entry, int index)
#define ICON_MD_CANCEL
Definition icons.h:364
#define ICON_MD_PLAY_ARROW
Definition icons.h:1479
#define ICON_MD_TERMINAL
Definition icons.h:1951
#define ICON_MD_BUILD
Definition icons.h:328
#define ICON_MD_HISTORY
Definition icons.h:946
#define ICON_MD_DELETE_SWEEP
Definition icons.h:533
std::vector< ProjectWorkflowHistoryEntry > workflow_history()
std::function< void()> cancel_build_workflow_callback()
ProjectWorkflowStatus build_workflow_status()
std::function< void()> run_project_workflow_callback()
std::function< void()> start_build_workflow_callback()
WorkflowButtonRect DrawCopyCurrentLogButton(const std::string &build_log)
std::string FormatHistoryTime(std::chrono::system_clock::time_point timestamp)
const char * WorkflowIcon(const ProjectWorkflowStatus &status, const char *fallback_icon)
WorkflowActionRowResult DrawHistoryActionRow(const ProjectWorkflowHistoryEntry &entry, const WorkflowActionCallbacks &callbacks, const WorkflowActionRowOptions &options)
ImVec4 WorkflowColor(ProjectWorkflowState state)
ImVec4 GetTextSecondaryVec4()
std::chrono::system_clock::time_point timestamp