Debian Codegraph @

src/gui/stats.cpp

raw
1 /**
2 * Furnace Tracker - multi-system chiptune tracker
3 * Copyright (C) 2021-2025 tildearrow and contributors
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "gui.h"
21 #include <fmt/printf.h>
22 #include <imgui.h>
23
24 void FurnaceGUI::drawStats() {
25 if (nextWindow==GUI_WINDOW_STATS) {
26 statsOpen=true;
27 ImGui::SetNextWindowFocus();
28 nextWindow=GUI_WINDOW_NOTHING;
29 }
30 if (!statsOpen) return;
31 if (ImGui::Begin("Statistics",&statsOpen,globalWinFlags,_("Statistics"))) {
32 size_t lastProcTime=e->processTime;
33 double maxGot=1000000000.0*(double)e->getAudioDescGot().bufsize/(double)e->getAudioDescGot().rate;
34 ImGui::AlignTextToFramePadding();
35 ImGui::Text(_("Audio load"));
36 ImGui::SameLine();
37 ImGui::ProgressBar((double)lastProcTime/maxGot,ImVec2(ImGui::GetContentRegionAvail().x-ImGui::CalcTextSize("100.0%").x,0),"");
38 ImGui::SameLine();
39 ImGui::Text("%.1f%%",100.0*((double)lastProcTime/(double)maxGot));
40 if (ImGui::GetContentRegionAvail().y>8.0f*dpiScale) {
41 // draw a chart
42 lastAudioLoads[lastAudioLoadsPos]=(double)lastProcTime/maxGot;
43 if (++lastAudioLoadsPos>=120) lastAudioLoadsPos=0;
44
45 ImGui::PushStyleColor(ImGuiCol_FrameBg,ImVec4(0,0,0,0));
46 ImGui::PlotLines("##ALChart",lastAudioLoads,120,lastAudioLoadsPos,NULL,0.0f,1.0f,ImGui::GetContentRegionAvail());
47 ImGui::PopStyleColor();
48 }
49 }
50 if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_STATS;
51 ImGui::End();
52 }