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#include "util/i18n/tr.h"
3
4#include "absl/strings/str_format.h"
7#include "imgui/imgui.h"
8
10
12 (void)p_open;
13
14 const auto build_status = ContentRegistry::Context::build_workflow_status();
15 const auto run_status = ContentRegistry::Context::run_workflow_status();
16 const auto build_log = ContentRegistry::Context::build_workflow_log();
17 const auto history = ContentRegistry::Context::workflow_history();
18 const auto cancel_build =
20
21 if (!build_status.visible && !run_status.visible && build_log.empty() &&
22 history.empty()) {
23 ImGui::TextDisabled(tr("No workflow output available yet."));
24 ImGui::TextWrapped(
25 tr("Run a project build or output reload to populate workflow status "
26 "and logs."));
27 return;
28 }
29
30 if (build_status.visible) {
31 DrawStatusCard(ICON_MD_BUILD, build_status);
32 if (build_status.can_cancel && cancel_build) {
33 if (ImGui::Button(ICON_MD_CANCEL " Cancel Build")) {
34 cancel_build();
35 }
36 }
37 ImGui::Spacing();
38 }
39
40 if (run_status.visible) {
42 ImGui::Spacing();
43 }
44
45 if (!build_log.empty()) {
46 ImGui::Separator();
47 ImGui::TextColored(gui::GetTextSecondaryVec4(), tr("%s Build Output"),
49 ImGui::SameLine();
50 DrawCopyCurrentLogButton(build_log);
51 if (ImGui::BeginChild("##workflow_output_log", ImVec2(0, 240), true,
52 ImGuiWindowFlags_HorizontalScrollbar)) {
53 ImGui::TextUnformatted(build_log.c_str());
54 if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) {
55 ImGui::SetScrollHereY(1.0f);
56 }
57 }
58 ImGui::EndChild();
59 }
60
61 if (!history.empty()) {
62 ImGui::Separator();
63 ImGui::TextColored(gui::GetTextSecondaryVec4(), tr("%s Recent History"),
65 ImGui::SameLine();
66 if (ImGui::SmallButton(ICON_MD_DELETE_SWEEP " Clear History")) {
68 }
69 for (size_t i = 0; i < history.size(); ++i) {
70 DrawHistoryEntry(history[i], static_cast<int>(i));
71 }
72 }
73}
74
76 const char* fallback_icon, const ProjectWorkflowStatus& status) {
77 ImGui::TextColored(
78 WorkflowColor(status.state), "%s %s", WorkflowIcon(status, fallback_icon),
79 status.summary.empty() ? status.label.c_str() : status.summary.c_str());
80 if (!status.detail.empty()) {
81 ImGui::TextWrapped("%s", status.detail.c_str());
82 }
83 if (!status.output_tail.empty()) {
84 ImGui::TextWrapped("%s", status.output_tail.c_str());
85 }
86}
87
89 const ProjectWorkflowHistoryEntry& entry, int index) {
90 ImGui::PushID(index);
92 callbacks.start_build =
94 callbacks.run_project =
96 const std::string title = absl::StrFormat(
97 "%s %s - %s", entry.kind.c_str(), entry.status.summary.c_str(),
98 FormatHistoryTime(entry.timestamp).c_str());
99 if (ImGui::CollapsingHeader(title.c_str(), ImGuiTreeNodeFlags_DefaultOpen)) {
101 entry.status);
102 DrawHistoryActionRow(entry, callbacks);
103
104 if (!entry.output_log.empty()) {
105 if (ImGui::BeginChild("##workflow_history_log", ImVec2(0, 120), true,
106 ImGuiWindowFlags_HorizontalScrollbar)) {
107 ImGui::TextUnformatted(entry.output_log.c_str());
108 }
109 ImGui::EndChild();
110 }
111 }
112 ImGui::PopID();
113}
114
115} // 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