MCPcopy Create free account
hub / github.com/MrDrElliot/LuminaEngine / DrawTask

Function DrawTask

Engine/Editor/Source/UI/SlowTaskModal.cpp:48–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46 }
47
48 void DrawTask(const FSlowTaskProgress& Task)
49 {
50 constexpr float SpinnerRadius = 8.0f;
51 constexpr float TextIndent = SpinnerRadius * 2.0f + 12.0f;
52
53 // The header row holds a spinner and bold title, vertically centered against each other.
54 const float RowStartY = ImGui::GetCursorPosY();
55 DrawSpinner(SpinnerRadius, 2.5f, ImGui::GetColorU32(GAccent));
56
57 ImGui::SameLine(0.0f, 12.0f);
58 ImGuiX::Font::PushFont(ImGuiX::Font::EFont::MediumBold);
59 const float TitleOffset = (SpinnerRadius * 2.0f - ImGui::GetTextLineHeight()) * 0.5f;
60 ImGui::SetCursorPosY(RowStartY + ImMax(0.0f, TitleOffset));
61 ImGui::TextUnformatted(*Task.Title);
62 ImGuiX::Font::PopFont();
63
64 // Message, indented to sit under the title.
65 if (!Task.Message.IsEmpty())
66 {
67 ImGui::SetCursorPosY(RowStartY + SpinnerRadius * 2.0f + 4.0f);
68 ImGui::Indent(TextIndent);
69 ImGui::PushStyleColor(ImGuiCol_Text, GMutedText);
70 ImGui::TextUnformatted(*Task.Message);
71 ImGui::PopStyleColor();
72 ImGui::Unindent(TextIndent);
73 }
74
75 ImGui::Spacing();
76
77 // An accent fill on a faint accent track, rounded.
78 const FFixedString Overlay = FormatAs<FFixedString>("{:.0f}%", Task.Fraction * 100.0f);
79
80 // The overlay percentage draws inside the bar, so it must clear a line of text plus padding.
81 constexpr float BarPaddingY = 3.0f;
82 const float BarHeight = ImMax(14.0f, ImGui::GetTextLineHeight() + BarPaddingY * 2.0f);
83
84 ImGui::PushStyleColor(ImGuiCol_PlotHistogram, GAccent);
85 ImGui::PushStyleColor(ImGuiCol_FrameBg, GAccentTrack);
86 ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
87 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, BarPaddingY));
88 ImGui::ProgressBar(Task.Fraction, ImVec2(-FLT_MIN, BarHeight), *Overlay);
89 ImGui::PopStyleVar(2);

Callers 1

RenderFunction · 0.85

Calls 15

DrawSpinnerFunction · 0.85
GetColorU32Function · 0.85
PushFontFunction · 0.85
ImMaxFunction · 0.85
TextUnformattedFunction · 0.85
PopFontFunction · 0.85
IndentFunction · 0.85
PushStyleColorFunction · 0.85
PopStyleColorFunction · 0.85
CtorSprintfClass · 0.85
PushStyleVarFunction · 0.85
PopStyleVarFunction · 0.85

Tested by

no test coverage detected